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

/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

 

 

 

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.