Jump to content

Include Files And Referencing


ravenshade
 Share

Recommended Posts

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

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:

  1. If it is just normal text data, output it:
    echo $my_var;

  2. If you want to parse the PHP, use eval():
    eval('?>' . $my_var . '<?php');

Link to comment
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...