5 Golden Rules of PHP Variables

Опубликовано: 21 Май 2026
на канале: PHP Explained
42
1

While declaring a variable in PHP, we have to follow a few rules.

1. PHP variable must start with a $ sign.

2. The very first character after the $ sign must be either a letter or a underscore. Letters are the English alphabets A to Z. The letter can be lowercase or uppercase.

3. From second character onwards, we can use letters, numbers, and underscore.

4. PHP variables are case-sensitive. It means two variables with same name and different cases forms two different variables. $name, $Name, and $NAME are three different variables in PHP.

5. PHP is a loosely typed language. So, there is no need to declare a variable before using it. We can declare a variable and start using it.