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, 1747🔥, 0💬
Popular Posts:
How To Read Data from Keyboard (Standard Input) in PHP? If you want to read data from the standard i...
How To Copy Array Values to a List of Variables in PHP? If you want copy all values of an array to a...
Where to find EPUB Sample Files? Here is a list of EPUB sample files collected by FYIcenter.com team...
What is Azure API Management Publisher Dashboard? Azure API Management Publisher Dashboard is an Azu...
How To Copy Array Values to a List of Variables in PHP? If you want copy all values of an array to a...