For a question about the PHP file reference, please take a look. thank you for a PHP question. please take a look at it. define a constant define ('script', 'index') in php and reference the file title. phprequire & nbsp; 'Title. for a question about php file reference, please take a look. thank you.
A php question. please take a look,
I define a constant in index. php.
Define ('script', 'index ');
And reference the file title. php.
Require 'Title. php ';
In title. php, I did not reference the index. php file, but I can also print the constant value in index. php.
Echo SCRIPT; // result index
Can the referenced php file use constants and variables in the referenced php file?
For example, index. php references title. php. Can I use the constants and variables defined in index. php? Share:
------ Solution --------------------
If you directly browse http: // localhost/title. php, the index cannot be printed, and the printed value is SCRIPT.
At that time, if you browse http: // localhost/index. php. it will be printed and the value is index.
In fact, I personally simply understood the reference and copied the code directly!
------ Solution --------------------
In
Require 'Title. php ';
The previously defined global variables or constants can be accessed in title. php.
------ Solution --------------------
Define ('script', 'index ');
Define defines global constants and can be accessed anywhere