Skip to main content

Posts

Showing posts from December 11, 2025

PHP Lesson 2

PHP Lesson 2: Variables and Data Types (The Building Blocks) Welcome back! In Lesson 1, you learned how to display simple text using echo . Now, we're going to learn how to store, manipulate, and reuse information using Variables . 📦 Understanding Variables A variable is essentially a container or a named memory location used to store data. Think of it like a label on a box: the label is the variable name, and whatever is inside the box is the value. In PHP, a few key rules apply to variables: Starts with $ : All variable names must begin with a dollar sign ( $ ). Assignment: We use the equals sign ( = ) to assign a value to a variable. Naming Rules: Variable names must start with a letter or an underscore ( _ ) and can only contain alphanumeric characters and underscores (A-z, 0-9, and _ ). They are case-sensitive (e.g., $name is different from $Name ). Basic Variable Declaration Here is how you declare a variable and then use the echo statement to display its value: PHP ...