Thursday, 18 May 2017

Include one PHP file into another



I need to include one PHP file into another. The PHP file that needs to be included sits in a separate directory though. This is how it is set up:



folder1/global-functions.php
folder1/folder2/functions.php


I need to include the 'global-functions.php' in the 'functions.php'




I tried:






But this will not work. It returns this error message:




Warning: include(../global-functions.php) [function.include]: failed to open stream: No such file or directory in /home/user/public_html/wp-content/themes/folder1/folder2/custom_functions.php on line 2




Warning: include() [function.include]: Failed opening '../global-functions.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/user/public_html/wp-content/themes/folder1/folder2/custom_functions.php on line 2



Answer



Try including the file with an absolute path: something like this:





No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...