Set_include_path and get_include_path usage and precautions

Source: Internet
Author: User
Set_include_path: sets the default include path. This article describes how to use it and its precautions. if you are interested, you can understand it. it may be helpful for you to learn about php. set_include_path: sets the default include path.
Find the include or require file in the default include path and then in the same directory
Example:
D:/xampp/htdocs/test/include has a file named cls. mysqli. php.
D:/xampp/htdocs/test/has a file named set_include_path.php.
The content is
The code is as follows:
Set_include_path ('/xampp/htdocs/test/include'); // note that '/' in php indicates not the root directory of the website, but the drive letter of the file, available echo realpath ('/'); view
// If the php version is too low, this function is not supported and can be used in the general version of ini_set ()
/* View the actual default include path */
Echo realpath (get_include_path ());
/* To include cls. mysqli. php, you only need */
Require_once ('cls. mysqli. php ');
$ Mysql = new Mysql ('localhost', 'root', '', 'test'); // The instantiated and subsequent query statements are correct.

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.