copy file content to string variable
Moderator: General Moderators
copy file content to string variable
Is there any function in php library that will copy the contents of a text file into string ??
Re: copy file content to string variable
I believe file_get_contents() is what you're looking for.
http://php.net/manual/en/function.file-get-contents.php
Use with stripslashes:
http://php.net/manual/en/function.file-get-contents.php
Use with stripslashes:
Code: Select all
//set file name
$file = 'myfile.html';
//echo contents of file
echo(stripslashes(file_get_contents($file)));
//echo contents of file exactly (will display special chars in browser)
echo(htmlentities(stripslashes(file_get_contents($file))));
Re: copy file content to string variable
Thank you very much !!!! 