The readfile function simply outputs the file, rather than allowing you to set a string variable for that file's contents. In fact, the return value of the function is the number of bytes read, so $output in Anikin's example above would be something like 4556, or whatever, but the rest of the contents of the page would echo out anyway, since that is what readfile does (
What you need is to use one of the other PHP file access functions. Unfortunately, there is no single function in PHP that let's you just set a variable equal to a remote file, but the file() (
command is the closest. It actually returns an array for each line of the file, which can be a very useful thing in itself. And to get a regular string variable out of it, you just need to use a join() (
You can nest these functions for nice compact code.
So, if you want to take a user's input, grab the HTML page that the user requests, place it in a <textarea> box for editing, you can do something like:
Code:
$output = join("",file($users_input_url));
//join the array with a null string
fix_output = htmlentities($output);
//escape HTML tags that will 'break out' of
//the textarea tagset
echo "<textarea>$fix_output</textarea>;
//... finish with the rest of your form //to submit user's edited version
-------------------------------------------
"Calculus is just the meaningless manipulation of higher symbols"
-unknown F student