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
Post a Comment