Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I know which include path will be used in PHP?
    text
    copied!<p>When I run <code>phpinfo()</code> and look by the <code>Configuration</code> category under <code>PHP Core</code>, I see a directive titled <code>include_path</code>, with a local value and a master value.</p> <p>In this case, my local value is set to</p> <pre> .: ./include: ../include: /usr/share/php: /usr/share/php/smarty: /usr/share/pear </pre> <p>and my master value is set to</p> <pre> .: /usr/share/php: /usr/share/pear: /usr/share/php/pear: /usr/share/php/smarty </pre> <p>The reason I am trying to learn how this works is because there is a file in the system I am working on titled <code>Smarty.class.php</code>, which I'm sure sounds very familiar to anyone who uses Smarty Templating Engine.</p> <p>One of the PHP files has the following includes:</p> <pre> require_once("Smarty.class.php"); require_once("user_info_class.inc"); </pre> <p>The file <code>user_info_class.inc</code> is in the same directory as the file making the include, which makes perfect sense to me, and is the way that I've always referenced files. I decided that I wanted to open up the Smarty.class.php file and had assumed it would be in the same directory, but it was not.</p> <p>After doing a bit of digging, I discovered those <code>php_ini</code> variables, and was finally able to locate the file in the directory <code>usr/share/php/smarty/</code>.</p> <p>So it would seem that when making an include, it follows some sort of order between the Local and Master values for the <code>include_path</code>.</p> <p>Assuming that my deductions were correct thus far, can someone explain the order in which PHP searches for the files to be included?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload