There are three types of scope of variable :
- Local variable
- Global variable
- Static variable
<!DOCTYPE html> <html> <head> <title>Shivam's web</title> </head> <body> <?php $a=2; function dis() { $a=1;//loacl echo "loacl a=",$a; global $a; echo "<br/>gloabl a=",$a; echo "<br/>"; } echo dis().$a ?> </body> </html>
<!DOCTYPE html> <html> <head> <title>Shivam's web</title> </head> <body> <?php $a=2; function dis() { $a=1;//loacl echo "loacl a=",$a; global $a; echo "<br/>gloabl a=",$a; echo "<br/>"; } echo dis().$a ?> </body> </html>
<!DOCTYPE html> <html> <head> <title>cwipedia.in</title> </head> <body> <?php function dis() { static $a=0; $a++; return $a; } echo dis(),"<br/>"; echo dis(),"<br/>"; echo dis(),"<br/>"; ?> </body> </html>
- Scope of variables in PHP
- Example of Local variable in PHP
- Example of global variable in PHP
- Example of static variable in PHP
- How to access local variable outside the function in PHP

Comments
Post a Comment
If you have any query, please let us know