Friday 15 June 2012

php - Relative includes dont work anymore after moving to IIS? -


OK, I've seen a lot of glimpse of PHP () instructions here. It seems that it has also become a cause of sadness for me.

My site structure is something like this:

  public_html \ index.php public_html \ include \ content.inc .php public_html \ language \ language.inc.c.php Public_html \ classes \ db.inc.php  

No problems spread over the site Apache. It does not work on IIS (grr ... # @ !!!%)

Explain to me: What is done is that index.php is always called on the web browser and request, in it content.inc.php (many of these are content files and include the appropriate one based on logic in index.php)

  // - index.php - included (included / content.inc) .php);  

So far it works well on both Apache and IIS.

Now content.inc.php Lang Inc.php and db.inc.php in return.

It looks like:

  // - content.inc.php - include (language / n / language .php) (classes / db Inc.php)  

These lines work well on Apache but IIS complains that they can not file to include the file.

Why? Because Apache maintains the current folder "." public_html \ is where the script execution was started first. On the other hand, the meaning of "IIS" varies. Due to the file being currently being processed, after adding I.e content.inc.php, the interpretation of IIS is "." As it is included in public_html \

Now I know that there is a way to change the way that in some way the path is fully incorporated. But my question is, is it really an Apache / IIS problem as I think? Is there an IIS or PHP setting to behave in a right way without any kind of code?

Div class = "post-text" itemprop = "text">

Your included files should be completely outside your public_html tree

 // You should have the same setup: / public_html / index. Php / include / / include / languages ​​/ include / classes // If they are similar to your phsical drive; C: /wwwroot/public_html/index.php c: / wwwroot / include / c: / wwwroot / include / languages ​​c: / wwwroot / include / classes 

then settings in your PHP.INI file It can be converted into:

include_path = "; .c \ PHP \ pear; C: \ wwwroot \" contains

where I was guessing something like wwwroot That's the directory on which you change your html, as needed.

Restart the IIS service to select the new UI setting.

 echo ini_get ('include_path'); 

To maintain your discretion ...

Now PHP will always look inside wwwroot / contains it for your included files, so that you can do this by doing things like / languages Can be included;

Include 'language / engineering / language .info';

Which one do you want.


No comments:

Post a Comment