Tools, FAQ, Tutorials:
Local Variables in a Function in PHP
What Is the Scope of a Variable Defined in a Function? in PHP?
✍: FYIcenter.com
The scope of a local variable defined in a function is limited with that function. Once the function is ended, its local variables are also removed. So you can not access any local variable outside its defining function. Here is a PHP script on the scope of local variables in a function:
<?php
?>
function myPassword() {
$password = "U8FIE8W0";
print("Defined inside the function? ". isset($password)."\n");
}
myPassword();
print("Defined outside the function? ". isset($password)."\n");
?>
This script will print:
Defined inside the function? 1 Defined outside the function?
⇒ Global Variables in Main Script in PHP
⇐ Returning an Array from a Function in PHP
2016-12-08, ∼2250🔥, 0💬
Popular Posts:
How To Move Uploaded Files To Permanent Directory in PHP? PHP stores uploaded files in a temporary d...
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...
What's Wrong with "while ($c=fgetc($f)) {}" in PHP? If you are using "while ($c=fgetc($f)) {}" to lo...
How to use the "rewrite-uri" Policy Statement for an Azure API service operation? The "rewrite-uri" ...