echo php code by php; is that possible -
i want echo out php code educational purposes. possible? @ same time need code php code executed.
adding html special-chars
this:
$this->art = file_get_contents("$this->mainpage/$this->dir/$this->article");
it becomes:
$this->art = htmlspecialchars( file_get_contents("$this->mainpage/$this->dir/$this->artikel"));
but still not output code php interpreter seems hold of code , directly interprets it. htmlspecialchars ()
has got effect on html code, see article in brackets.
i tried using .html
files instead of .php
files. php interprets if rename .jpeg
.
i'm @ wit's end. grateful answer. thanking in advance.
i dont understand, why 1 consider doing way, pretty easy. file_get_content not run code, while include will.
define('ds', directory_separator); // logic starts here public function main() { echo '<hr><pre>' . $this->educlude($this->mainpage . ds. $this->dir . ds . $this->artikle) . '</pre>'; } public function educlude($file) { include $file; return htmlspecialchars(file_get_contents($file)); }
this echo
hello world
<?php echo 'hello world';
for given file:
<?php echo 'hello world';
Comments
Post a Comment