How to add template in codeigniter |how to create template in codeigniter| template in codeigniter 4
PHP Variable
The PHP variable is a containers, where you store some value that like form input fields values. Variable use for store session value, store database value and store array value in a array variable. For example $variable=”some data”;. Use semicolon after store data in a variable. Variable name is user define but you need to follow some rules to define a variable name. Read below content you can understand.
Validation of PHP variable
- PHP variable name starts with $ sign
- After $ sign, the variable must have alphabet or underscore(_) sign
- The variable name must not start with the number after $ sign.
- Space is not allowed of a variable name
Example of variable declaration:
<?php //valid variables are follows $_a=6; $a23=5; $abc=5; //Invalid variables declaration are follows $23a = 5; $ks kd=5; ajd$kd=5; ?>
- Do not use space in a variable name.
- Do not start variable with number digit.
- Don’t forget to use $ sign before define a variable name.
PHP Variables Scope
Write PHP code nicely and variables can be declared anywhere in the script code. Know the scope: in PHP the scope of a variable is the part of the PHP script where the variable can be used.
In PHP has three different variable scopes, that’s are:
- Local variable.
- Global variable.
- Static variable.
Related posts