apache - PHP include with http not working -
here include file data.php:
<?php $name = "noob"; ?> this file in local server online server.
and here code:
<?php //include("./data.php"); //include("http://localhost/webdev/test/php/remote_include/data.php"); //include("http://example.com/data.php"); echo "hello $name."; ?> now, in 3 commented lines, first line works, , hello noob. printed. next 2 lines not work , hello . printed.
why?
my guess is, when include using http, php file gets run , main script (which calls include) not know variables set , can see php prints. correct? if that's case, data.php file (which in online server) has top secret database information of awesome (noob) blog site. cannot include() file (using http or other possible method) , database info echoing variables?
sorry if it's noob of question , has been asked before.
from the manual:
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.
basically, http://php.net/manual/en/function.include.php needs enabled include files via http. turned off on shared hosts don't want eat bandwidth incur.
Comments
Post a Comment