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, 4474🔥, 0💬
Popular Posts:
How To Convert a Character to an ASCII Value? If you want to convert characters to ASCII values, you...
Where to find tutorials on API Management Services at Azure Portal? Here is a list of tutorials to a...
How to attach console to a Running Container using the "docker container exec" command? I want to ge...
What are the differences of Differences of evaluateTransaction() and submitTransaction() of the fabr...
How to run PowerShell Commands in Dockerfile to change Windows Docker images? When building a new Wi...