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, ∼6476🔥, 0💬
Popular Posts:
Where can I download the EPUB 2.0 sample book "The Problems of Philosophy" by Lewis Theme? You can f...
How To Loop through an Array without Using "foreach" in PHP? PHP offers the following functions to a...
What Is Azure API Management Service? Azure API Management as a turnkey solution for publishing APIs...
How to view API details on the Publisher Dashboard of an Azure API Management Service? You can follo...
What is Fabric CA (Certificate Authority)? Fabric CA (Certificate Authority) is a component of Hyper...