PHP include file by relative path -
this absolute path includes file httpapi.inc.php:
require_once '/home/devel/wwwroot/nm/dev/http-api/http-api/src/httpapi.inc.php';
the calling file is:
caller relative:
/devel/phi/dev/appcenter-head/appcenter/application/nm/index.php
caller location:
/home/devel/wwwroot/phi/dev/appcenter-head/appcenter/application/nm
now, how can include same file based on relative path like:
/devel/nm/dev/http-api/http-api/index.php
i must use path "as is", since config option passed user.
require() , include() should operate relative configured include paths , executing script. so, should work:
require_once('src/httpapi.inc.php'); to precise, though, current script's working directly designated 1 of include paths in default configuration. won't work if you've mucked it.
using . in include path allows relative includes means current directory.
regarding latest edit, paths different enough it's simpler use full path or add /home/devel/wwwroot/nm/dev/http-api/http-api/ config , use require_once('src/httpapi.inc.php').
Comments
Post a Comment