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, 4574🔥, 0💬
Popular Posts:
How to use the "find-and-replace" Policy Statement for an Azure API service operation? The "find-and...
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...
How to decode the id_token value received from Google OpenID Connect authentication response? Accord...
What validation keywords I can use in JSON Schema to specifically validate JSON Array values? The cu...
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...