ravenshade Posted September 13, 2009 Share Posted September 13, 2009 My question is, is it possible to use absolute references in include files and if so how. I tried to do it myself but it didn't quite work so I was wondering if I was using the correct syntax...include("http://www.test.com/Code/subject.php"); Link to comment Share on other sites More sharing options...
Synook Posted September 13, 2009 Share Posted September 13, 2009 No, you can't, because that would be a horrible security flaw (what if some private variables were declared in that file, e.g. database passwords?). You have to use file_get_contents() instead. Link to comment Share on other sites More sharing options...
ravenshade Posted September 13, 2009 Author Share Posted September 13, 2009 Hmmm does file_get_contents work like include() then? Link to comment Share on other sites More sharing options...
Ingolme Posted September 13, 2009 Share Posted September 13, 2009 Hmmm does file_get_contents work like include() then?Not exactly. file_get_contents will store the content of the file in a variable, like this:$my_var = file_get_contents("file.php"); You can then do either of the following: If it is just normal text data, output it:echo $my_var; If you want to parse the PHP, use eval():eval('?>' . $my_var . '<?php'); Link to comment Share on other sites More sharing options...
justsomeguy Posted September 14, 2009 Share Posted September 14, 2009 If you include a file using the HTTP path, you're not including the source code, you're including the output. If you want to include the source code do not use the HTTP path, use the local file path. If the file is on another server you need to connect and download the file using FTP and then include the code. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.