Heredoc with eval code execution

I tried several methods to try to get this working, but no luck!

I have a page like this (Example):

<?php $jj = <<<END ?> <h1>blah blah</h1> <p> blah blah blah blah blah blah blah <?php include("file.php"); ?> blah blah</p> <?php END; eval('?>'.$jj.'<?php '); ?> 

this does not lead to the conclusion that so never can come up with a solution!

0
source share
1 answer

This will not work because eval expects only PHP code (i.e. not surrounded by <? Php?> Tags), so the call to eval () will probably fail with a parsing error.

I would suggest using output buffering instead, for example:

 <?php //start output buffering, anything outputted should be stored in a buffer rather than being sent to the browser ob_start(); ?> <h1>blah blah</h1> <p> blah blah blah blah blah blah blah <?php include("file.php"); ?> blah blah</p> <?php //get contents of buffer and stop buffering $content = ob_get_clean(); echo $content; ?> 
+3
source

Source: https://habr.com/ru/post/1441361/


All Articles