How do you know the correct path to use in a PHP require_once() statement

后端 未结 9 2123
别跟我提以往
别跟我提以往 2021-01-31 22:02

As many do I have a config.php file in the root of a web app that I want to include in almost every other php file. So most of them have a line like:

require_on         


        
9条回答
  •  [愿得一人]
    2021-01-31 23:08

    I like to do this:

    require_once(dirname(__FILE__)."/../_include/header.inc");
    

    That way your paths can always be relative to the current file location.

提交回复
热议问题