Case-inconsistency of PHP file paths on Mac / MAMP?

前端 未结 4 720
日久生厌
日久生厌 2020-12-29 23:22

I\'m developing a PHP program on MAMP, and just realized the following screwy behavior:

echo \"
PATH = \".dirname(__FILE__); include \'include.php\
4条回答
  •  灰色年华
    2020-12-29 23:55

    I was using apache and I found that the __DIR__ of the executed file was the same one found in the DOCUMENT_ROOT of the apache config.

    That means that if the apache config had

    DocumentRoot /users/me/stuff/my_site
    

    script from the question was printing:

    PATH = /users/me/stuff/my_site (All lower case)
    
    PATH = /Users/me/stuff/my_site (Mixed case)
    

    And if the apache config had:

    DocumentRoot /Users/me/stuff/my_site
    

    script from the question was printing:

    PATH = /Users/me/stuff/my_site (Mixed case)
    
    PATH = /Users/me/stuff/my_site (Mixed case)
    

    Which was much better.

    If you encounter this problem, check the apache configuration taking into account that it's case sensitive.

提交回复
热议问题