Breaking
Loading...

Rules for PHP variables:

1. A variable starts with the $ sign, followed by the name of the variable
2. A variable name must start with a letter or the underscore character
3. A variable name cannot start with a number
4. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
5. Variable names are case sensitive ($y and $Y are two different variables)



The variables listed below are different variable:
$Name
$name
$NAME
$NAme

6. The variables in PHP are declared by appending the $ sign to the variable name.
               
               For e.g
               $company = “NCST”;
               $sum = 10.0;

7. Variable data type is changed by the value that is assigned to the variable.
8. Type casting allows to change the data type explicitly.
9. Rich set of functions for working with variable.
               
               For e.g.
               gettype, settype, isset, unset, is_int, intvaletc etc

PHP Variables Scope

# PHP has three different variable scopes:

       
1. Local - A variable declaredwithina function
2. Global - A variable declaredoutsidea function
3. Static - When a function is executed, all of its variables are deleted. If you want a local variable NOT to be deleted, use thestatickeyword

Assignment Operator

• PHP assignment operator is “=“.
• Syntax of the assignment operator:
             Variable = expression

Semantic of the assignment operator

– The right hand side expression to “=“ is computed and the result is assigned to the left hand side operand –assign by value
– In PHP assignment statement has a return value, which is the result of the expression on the right hand side.



Related Articles

  • PHP2017-07-26PHP සිංහලෙන් - VIII PHP Constant (PHP නියත ) - PHP Constant යනු එක්තරා විදියක variable එකක් … Read More
  • PHP2017-07-26PHP සිංහලෙන් - V Basic Syntax (මූලික කාරක රීති) PHP කාරක රීති යනු PHP කොටසක් නිවැරදිව ධාවන කරන්… Read More
  • PHP2017-07-26PHP සිංහලෙන් - II PHP Install කිරීම - PHP සමඟ වැඩ කිරීමට නම් ඒ සමඟ වැඩ කිරීමට මෘදුකාංග කිහිප… Read More
  • PHP2017-07-26PHP සිංහලෙන් - VII PHP Operators (මෙහෙයුම් සංකේත) - Operator එකක් යනු කිසියම් අගයන්  මත රද… Read More
  • PHP2017-07-26PHP සිංහලෙන් - X PHP - Decision Making විවිධ කොන්දේසි මත තීරණ ගැනීමට භාවිතා කරන ප්‍රකාශන කිහිපයක… Read More
  • PHP2017-07-26PHP සිංහලෙන් - VI PHP Variable (PHP විචල්‍යය) Variable යනු කිසියම් දත්තයක් හෝ තොරතුරක් අඩංගු … Read More