php - Error with variables when requiring from url -
note; problem not in require or include.( it's in variables) while requiring or including url facing strange error following:
require_once "http://".$_server['http_host'].'/engine/header.php';
this causing errors variables
undefined variables
while :
require_once '/engine/header.php';
doesn't cause problem!
sorry if have misspelled or written not understandable words.
your answer located here.
if "url include wrappers" enabled in php, can specify file included using url (via http or other supported wrapper - see supported protocols , wrappers list of protocols) instead of local pathname. if target server interprets target file php code, variables may passed included file using url request string used http get. not strictly speaking same thing including file , having inherit parent file's variable scope; script being run on remote server , result being included local script.
this means if include url, independent php execution outside of current scope. need pass variables via $_get
superglobal.
if include
/require
absolute/relative file paths, able access variables via scope.
Comments
Post a Comment