PHP Global Variables
The result is no output, how should global variables be defined and used?
Reply to discussion (solution)
$VFP _oledb_cstring= "Provider=vfpoledb.1;data source=d:/testoledb; Collating Sequence=machine ";
Testgol ();
function Testgol () {
Global $VFP _oledb_cstring;
echo $VFP _oledb_cstring;
}
It is not recommended to use the Global keyword, or to use the $globals Super global variable.
Put a yac on it. Shared memory between processes, very useful.
Do I need to declare it again at the time of invocation? .
This string is used to declare. The directory location of the VFP table, I want to use it as a configuration file to include
It is then used in the various FUNCTION of a PHP file to achieve this effect. It should be better to use that method.
You can also use $global Super global variables
$VFP _oledb_cstring= "Provider=vfpoledb.1;data source=d:/testoledb; Collating Sequence=machine ";
Testgol ();
function Testgol () {
echo $GLOBALS [' vfp_oledb_cstring '];
}
If your string is fixed, you can define it as a constant, and the range of constants is global. The constant can be accessed anywhere in the script without a tube-in-action area.
Using the constant problem is solved. Thank you for your trouble.