nested include/require not working php5.2

Suddenly happened to my scripts, some includes are not working after reconfiguring the server. According to this site w/c encountered the same issue nested includes don’t work in php5.2

I am not able to use includes or requires in nested files using php 5.2.3
(osx)

Including or Requiring files directly works.

Including files, that also have includes in them, does not.

Say you have this…

-TopDirectory
–index.php (contains include(“includes/top.php”); )
–includes (folder)
—config.php (contains echo “crap”; )
—top.php (contains include(“config.php”); )





When you load the index.php file you would expect the word “crap” to show,
but it does not. I think the getcwd is staying specific to the top folder,
so the path stays the same throughout.

This does not happen in 5.1.6

Is there a fix for this or is it PHP causing the problem?






Mike Yrabedra B^)>

This entry was posted in php and tagged , , , , , , . Bookmark the permalink.

9 Responses to nested include/require not working php5.2

  1. dreamluverz says:

    juz recently a friend found a way to solve this. If you could edit the php.ini change this line
    allow_url_include = On
    and you’re good to go :)

  2. Rob Hidalgo says:

    You should specify the full server path for the included file. For example, if the included file is located in a folder called “Scripts” in your home directory, then on Mac OS X, you would write:

    require_once(‘/Users/username/Scripts/filename.php’);

  3. dreamluverz says:

    I reinstalled my php and noticed that includes didn’t work and I noted the solution here http://dreamluverz.com/developers-tools/php/include-not-working-in-php5 and I remember the nested includes I wrote before which is this one that probably the issue is not on the allow_url_include because I had this setting OFF by default but still my nested includes work.

    So the main issue is turning on the short tags on php for php5. Just checkout the link I mentioned above.

  4. Ray Phillips says:

    I don't know if this is your problem or not, but after hours of trying to figure out a similar problem, I found the problem was caused by using “<?” to open the document instead of “<php”. Previous versions did not care. PHP5 does.

    -Ray

  5. Ray Phillips says:

    I don't know if this is your problem or not, but after hours of trying to figure out a similar problem, I found the problem was caused by using “<?” to open the document instead of “<php”. Previous versions did not care. PHP5 does.

    -Ray

  6. Ray Phillips says:

    I don't know if this is your problem or not, but after hours of trying to figure out a similar problem, I found the problem was caused by using “<?” to open the document instead of “<php”. Previous versions did not care. PHP5 does.

    -Ray

  7. dreamluverz says:

    Hi yes you're right. Then few months after that, I encountered the same issue again and finally found the solution. Yeah this thing <? code here ?> doesn't work and should be <?php code here ?> so instead of changing all my codes to the latter example I juz turned on the “short_open_tag”.

    Details on this link http://dreamluverz.com/developers-tools/php/inc….

  8. Lavanya says:

    Hi , great, finally I don’t have to break my head again. For the ones who get this error after upgrading from php4 to php5 ” for inclusion (include_path=’.;C:\php5\pear’) ” look out if this is the problem: I just had to change to and everything is working fine again! THANKS (somehow I didn’t manage to change the short_open_tag to On, but I had anyhow only one file with the short tag.)

  9. Lavanya says:

    why is this important part always not displayed in the comment? change to

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>