willsherwood
asked on
PHP REQUIRE file input to PHP STRING
I currently have a sort of template file that encompasses text, HTML tags, and <?=PHP expressions?>
I currently use a REQUIRE to effect the "ECHOing"/execution of it to display it in a web page.
I now need that executed text result in a PHP STRING.
how do i get the text WITH the executed PHP expressions from the file into a PHP STRING variable?
thanks
I currently use a REQUIRE to effect the "ECHOing"/execution of it to display it in a web page.
I now need that executed text result in a PHP STRING.
how do i get the text WITH the executed PHP expressions from the file into a PHP STRING variable?
thanks
Like Filegetcontents()?
ASKER
but this leaves the PHP expressions unexecuted?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i couldn't find how to get this to work $StringVar = REQUIRE("file.php");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm sorry this is so confusing.
I do not want to display anything.
I would like to get the contents of a file into a string.
I would like the string to be "executed" for any PHP expressions amongst the text and HTML tags in the file.
File contents example -- file1.php:
<p>Hello <?="W"."orld"?> </p>
[EOF]
and i want to get that into string $string so that the string
contains "<p>Hello World </>"
thanks
I do not want to display anything.
I would like to get the contents of a file into a string.
I would like the string to be "executed" for any PHP expressions amongst the text and HTML tags in the file.
File contents example -- file1.php:
<p>Hello <?="W"."orld"?> </p>
[EOF]
and i want to get that into string $string so that the string
contains "<p>Hello World </>"
thanks
Ok, so output buffering should do that for you :)
ob_start();
require 'file1.php';
$string = ob_get_contents();
ob_end_clean();
ASKER
got it, thanks for your patience.
ASKER
thanks all