Web Design Tutorials Made Easy


PHP Include Hell |

With Microsoft Windows applications you have something called “dll hell”. Anyone who has tried to deploy a app knows what I am talking about when I say “dll hell”. PHP has its own version of “dll hell” called “include hell”. “Include hell” comes when you are including multiple versions of a particular php file in one php script that wants a particular version, this usually happens with PEAR, for example; a older version is installed by the host and included in php.ini; the customer rolls their own version of PEAR and includes in it via .htaccess; and a package comes with its own version of PEAR and includes it by file. Thus we have three different versions of PEAR floating around and causing function creation errors.

The moral of this story is to check your include path when having random/unexplained errors you might be surprised what you find there.

TO check the path use:

From PHP.net

// Works as of PHP 4.3.0

echo get_include_path();

  // Works in all PHP versions

echo ini_get('include_path');

One Response to 'PHP Include Hell'
  1. Anonymous:

    One mistake that gets you into one huge tangle is when you start making copies of your include files into different directories on the server.

    This is a big No No. All common include’s should be in a common directory and if they need to be modified they should get a NEW NAME. Else you are going to get a million ‘cannot redeclare class’ error’s later on.

    If you are using version control such as Subversion, use external dependancies. Don’t make duplicate API’s across your applications.

Leave a Reply

*required

*required / not published

Categories
Archives