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, ∼2251🔥, 0💬
Popular Posts:
FYIcenter.com Online Tools: FYIcenter JSON Validator and Formatter FYIcenter JSON to XML Converter F...
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...
How to install .NET Framework in Visual Studio Community 2017? I have the Visual Studio Installer in...
Where to find tutorials on JSON (JavaScript Object Notation) text string format? I want to know how ...
How to detect errors occurred in the json_decode() call? You can use the following two functions to ...