file_get_contents with relative path

前端 未结 4 676
孤独总比滥情好
孤独总比滥情好 2020-12-08 19:29

I have the following directory structure.

/var/www/base/controller/detail.php
/var/www/base/validate/edit.json
/var/www/html

Within /

4条回答
  •  难免孤独
    2020-12-08 19:44

    Of cause there is the possibility to use the include_path parameter. Set this parameter to '1' then a search for the file in the include_path (in php.ini.) will be done. You have to do editing in the php.ini!

    When using $json=file_get_contents('detail.php'); a call is done from a php file. Use file_get_contents('detail.php'); to have the detail.php get executed. the file have to be in the root directory (same as the calling php file in which the file_get_contents() is situated). If detail.php is in a subdirectory i can not see any workaround than using the include_path parameter

提交回复
热议问题