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, 1602🔥, 0💬
Popular Posts:
How to use the "Ctrl-p Ctrl-q" sequence to detach console from the TTY terminal of container's runni...
What is EPUB 2.0 Metadata "dc:creator" and "dc:contributor" elements? EPUB 2.0 Metadata "dc:creator"...
How to create Hello-3.1.epub with WinRAR? I have all required files to create Hello-3.1.epub. To cre...
How To Break a File Path Name into Parts in PHP? If you have a file name, and want to get different ...
How To Open Standard Output as a File Handle in PHP? If you want to open the standard output as a fi...