Answer the question
In order to leave comments, you need to log in
PHP: Is it possible to process content received with the require function?
Good afternoon!
Can you please tell me if it's possible to process the content received with the require() function with your own function? Something like this:
Tried like this:sobstvennayaFunctsiya( require( 'content.php' ) );
$p = function() {
return require('content.php');
}
echo sobstvennayaFunctsiya( $p );
file_get_contents
, but it is not suitable if the inserted file contains php tags - they are simply escaped and the php code is not executed. And I need to get the already executed html and php code and process it with my own function. Answer the question
In order to leave comments, you need to log in
https://codepen.io/anon/pen/NZpoqQ?editors=1010
-
https://developer.mozilla.org/en-US/docs/Web/API/W...
Well, either as Camaro67 wrote, or just_hank_moody already said about buffering.
ob_start();
require(<файл>);
$content = ob_get_contents();
ob_clean();
echo $content; //в $content лежит содержимое <файл>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question