PHP variables can take any type of data and change their type within the page also. ( in above example $my_var changes with type of data ) . It depends on its most recent assignment.
Scope of Variable
Local & Global
The variables declared as global are available throughout the script ( including inside the functions ).
Variables declared inside functions is know as local variable ( to that function ) and are only available inside the function. So local variables declared inside a page are not available inside the functions of the page.
Output is here. See how static variable value is retained after execution of first call of the function whereas the local variable is destroyed.
Static varaible :1, Local Variable :1
Static varaible :2, Local Variable :1
Life of a variable
All variables are used within the page or within the script present in a page. As you are reading this page some variables are used to display the content of the page. These variables are lost as soon as this page execution is completed at server and downloaded to your browser. So how to pass the data or retain the data across the pages ?