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, 3277👍, 0💬
Popular Posts:
How to add images to my EPUB books Images can be added into book content using the XHTML "img" eleme...
How to use .NET CLR Types in Azure API Policy? By default, Azure imports many basic .NET CLR (Common...
Where to find tutorials on Visual Studio? I want to know How to learn Visual Studio. Here is a large...
What is EPUB 3.0 Metadata "dc:publisher" and "dc:rights" elements? EPUB 3.0 Metadata "dc:publisher" ...
How to use the "send-request" Policy statement to call an extra web service for an Azure API service...