Tools, FAQ, Tutorials:
Accessing Global Variables inside a Function in PHP
How To Access a Global Variable inside a Function? in PHP?
✍: FYIcenter.com
By default, global variables are not accessible inside a function. However, you can make them accessible by declare them as "global" inside a function. Here is a PHP script on declaring "global" variables:
<?php
?>
$intRate = 5.5;
function myAccount() {
global $intRate;
print("Defined inside the function? ". isset($intRate)."\n");
}
myAccount();
print("Defined outside the function? ". isset($intRate)."\n");
?>
This script will print:
Defined inside the function? 1 Defined outside the function? 1
⇒ Function Returns Data by Value in PHP
⇐ Global Variables in Main Script in PHP
2016-12-08, ∼5572🔥, 0💬
Popular Posts:
Where Is the Submitted Form Data Stored in PHP? When a user submit a form on your Web server, user e...
How To Create an Array with a Sequence of Integers or Characters in PHP? The quickest way to create ...
How to pull NVIDIA CUDA Docker Image with the "docker image pull nvidia/cuda" command? If you are ru...
How to add request query string Parameters to my Azure API operation to make it more user friendly? ...
How to build a test service operation to dump everything from the "context.Request" object in the re...