Jump to content

Why are my included files getting included ?


Recommended Posts

Hi Folks,   

 

I inherited an already configured website with my new position as a LAMP programmer here in Richmond VA.

 

My httpd.conf file does not have the PHPiniDir parm.  php.ini is from /etc/php.ini, but I can't figure out how php decided to use that file, and my include_path as shown in phpinfo() is .;/usr/share/pear;/usr/share/php

 

BUT , files included from DOC_ROOT php scripts from include/somePHPFile.php or javascript/someOtherPHPScript.php get included just fine.  What gives ?  Why no "unable to include file" messages from the compiler ?

 

I have read that these directives could be in a .htaccess file, but I haven't been able to find any.

 

Any help / clarification will be appreciated.

 

Thanks,

 

Scot L. Diddle, Richmond VA

Link to comment
Share on other sites

/etc/php.ini is probably the default location that was compiled into PHP.

 

And the "." in the include path means current location.

 

 

For example:

 

/location/to/some/file.php

<?php

include 'file2.php';

 

 

In this order, PHP would look for:

 

./file2.php (which is equivalent to /location/to/some/file2.php)

/usr/share/pear/file2.php

/usr/share/php/file2.php

 

 

 

Link to comment
Share on other sites

Hi Corbin,

 

    Yep, I did find: '--with-config-file-path=/etc' in my ini info display.  If a leading dot works for includes, why worry about an include path at all ?  Is this to restrict includes to just those foldders found in the include path directive ?  Thanks for the input.

 

Scot L. Diddle, Richmond VA

Link to comment
Share on other sites

No, it is not to restrict.  It's actually to help.

 

 

For example, you can have common files any application can access in the same location without having to use an absolute path.

 

(PEAR is typically added to the include_path variable for example.)

 

 

If you want to limit what directories PHP can access, there is a variable, but I don't remember what it is.  I'm sure googling could find it.  I think it's something like include_top_directory or something.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.