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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -