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, ∼2836🔥, 0💬
Popular Posts:
Where to find tutorials on HTML language? I want to know how to learn HTML. Here is a large collecti...
How to add an API to an API product for internal testing on the Publisher Portal of an Azure API Man...
How To Protect Special Characters in Query String in PHP? If you want to include special characters ...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...
How To Truncate an Array in PHP? If you want to remove a chunk of values from an array, you can use ...