Cainiao: How does php define an array of file scopes?
global $param_array = array('P', 'Q', 'CR', 'LT', 'TC,M1', 'TC,M2', 'RI,M1', 'RI,M2');
The display syntax is incorrect. how can this array have a file scope?
Or is the file scope of an array impossible?
Reply to discussion (solution)
What does file scope mean?
Global cannot be used that way. you can check the manual.
What does file scope mean?
Global cannot be used that way. you can check the manual.
Sorry, I don't know much about php.
What is the scope of the script?
For example:
If array a is defined in a. php, its scope is a. php. all functions can access this array.
But it cannot be accessed in B. php.
No special definition
1. define an array
$ A = array (1, 2, 3, 4, 5)
So its scope is in this file, all functions can be accessed.
Defined in a. php, the array is a global variable by default, which can be used directly outside the function. the function must declare global $ a before it can be used.
$param_array = array('P', 'Q', 'CR', 'LT', 'TC,M1', 'TC,M2', 'RI,M1', 'RI,M2');function local(){global $param_array;print_r($param_array);}class localclass{function run(){global $param_array;print_r($param_array);}}print_r($param_array);local();$obj = new localclass();$obj->run();