PHP / PHP VariablesIn PHP, Variable is a data named used to store a data value and variable starts with the $ sign followed by the name of the variable.Example $a = "PHP Variable"; Rules for declaring variables in PHP 1. It starts with the $ sign symbol followed by its name / variable name. 2. Its name must start with a letter / underscore character and can’t be start with a number. 4. Its name can only contain alpha-numeric characters and underscores (_, A-z and 0-9) 5. Its names are case-sensitive ($salary and $SALARY are different variables) PHP Variables Scope Any PHP variables can be declared anywhere in the script / program. It refers to the visibility/ availability of variables. I.e For which parts of your program can see / use it. It is very useful to be able to limit a variable's scope to a single function. PHP variable has 3 scopes. They were
|