<p>I have tried both of :</p>

<pre><code>ini_set('include_path', '.:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes');
</code></pre>

<p>and also :</p>

<pre><code>php_value include_path ".:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes"
</code></pre>

<p>in the .htaccess file.</p>

<p>Both methods actually <strong>do work</strong> but only intermittently. That is, they will work fine for about 37 pages requests and then fail about 42 pages requests resulting in an require() call to cause a fatal error effectively crashing the site.</p>

<p>I'm not even sure where to begin trying to find out what is going on!</p>

<hr>

<p>@<a href="https://stackoverflow.com/questions/41836/setting-include-path-in-php-intermittently-fails-why#41877">cnote</a></p>

<blockquote>
  <p>Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.</p>
</blockquote>

<p>The in script version was originally </p>

<pre><code>ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . 'lib' . PATH_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'classes');
</code></pre>

<p>and thus the .:.: was coming from the existing path:</p>

<pre><code>ini_get('include_path')
</code></pre>

<p>I tried removing it anyway and the problem persists.</p>

[{'answer_id': 41877, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.</p>\n"}, {'answer_id': 42336, 'author': 'Ian', 'author_id': 4396, 'author_profile': 'https://Stackoverflow.com/users/4396', 'pm_score': 2, 'selected': False, 'text': '<p>Have you tried <a href="http://www.php.net/manual/en/function.set-include-path.php" rel="nofollow noreferrer">set_include_path()</a>?.  As a benefit this returns false on failure, allowing you to at least catch the occurence and generate some meaningful debug data.\nAdditionally, you should be using the constant <code>PATH_SEPARATOR</code> as it differs between windows / *nix.</p>\n\n<p>As a specific example:</p>\n\n<pre><code>set_include_path(\'.\' . PATH_SEPARATOR . \'./app/lib\' . PATH_SEPARATOR . get_include_path());\n</code></pre>\n\n<p>(the get_include_path() on the end means whatever your ini / htaccess path is set to will remain)</p>\n'}, {'answer_id': 2227991, 'author': 'Ramon de la Fuente', 'author_id': 227941, 'author_profile': 'https://Stackoverflow.com/users/227941', 'pm_score': 3, 'selected': True, 'text': '<p>It turned out the issue was related to a PHP bug in 5.2.5</p>\n\n<p>Setting an "admin_flag" for include_path caused the include path to be empty in some requests, and Plesk sets an admin_flag in the default config for something or other. An update of PHP solved the issue.</p>\n\n<p><a href="http://bugs.php.net/bug.php?id=43677" rel="nofollow noreferrer">http://bugs.php.net/bug.php?id=43677</a></p>\n'}]
['https://Stackoverflow.com/questions/41836', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/319/']