If you have any questions about php file reference, please take a look. thank you.

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.