Include php code within echo from a random text -


i want display php code @ random , have

<?php  // load file contain thecode $adfile = "code.txt"; $ads = array();  // 1 line per code $fh = fopen($adfile, "r"); while(!feof($fh)) {    $line = fgets($fh, 10240);   $line = trim($line);   if($line != "") {     $ads[] = $line;   } }  // randomly pick code $num = count($ads); $idx = rand(0, $num-1);  echo $ads[$idx]; ?> 

the code.txt has lines like

<?php print insert_proplayer( array( "width" => "600", "height" => "400" ), "http://www.youtube.com/watch?v=xnpcpcvepcg"); ?> 

proplayer wordpress plugin displays video. codes in code.txt work well, not when use pick line code.txt. instead of full php line get:

"width" => "600", "height" => "400" ), "http://www.youtube.com/watch?v=xnpcpcvepcg"); ?> 

how can make echo show php code, rather txt version of php code?

try using htmlentities() escape php code. like:

$string = '<?php print insert_proplayer( array( "width" => "600", "height" => "400" ), "http://www.youtube.com/watch?v=xnpcpcvepcg"); ?>'; echo htmlentities($string); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -