php - include fails if file is in another directory -
i trying include php file has functions in it. original plan store in different directory, when that, include fails.
here mean:
var_dump(file_exists("/dir/functions.php")); // returns bool(false) var_dump(file_exists("dir/functions.php")); // returns bool(false) var_dump(file_exists("http://www.example.com/dir/functions.php")); // returns bool(false) var_dump(file_exists("functions.php")); // returns bool(true) if place file in same directory var_dump(include("/dir/functions.php")); // returns bool(false) var_dump(include("dir/functions.php")); // returns bool(false) var_dump(function_exists(somefunction));// returns bool(false) var_dump(include("functions.php"));// returns bool(true) if place file in same directory var_dump(function_exists(somefunction));// returns bool(true)
what doing wrong? checked , files there, , have read , execute permission, i.e. 755
function include requires full server path or path relative directory calling script located since directory structure
www.example.com/site/index.php www.example.com/dir/functions.php
the correct call relative path is
include("../dir/functions.php");
Comments
Post a Comment