3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $htmlentitiesTabel = get_html_translation_table(HTML_ENTITIES); function Kleuren($code) { global $htmlentitiesTabel; $code = trim($code); $aantal = substr_count($code,"\n")+1; $gekleurd = highlight_string($code,true); $gekleurd = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $gekleurd); $gekleurd = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $gekleurd); $tabel = $htmlentitiesTabel; unset($tabel['<']); unset($tabel['>']); unset($tabel['&']); unset($tabel['\'']); unset($tabel['"']); $gekleurd = strtr($gekleurd, $tabel); $breedte = strlen($aantal)*7; $hoogteblok = $aantal > 25 ? "308" : $aantal*12+26; $hoogteregels = $aantal*12+16; $blok = "<div class='Codeblok' style='height: $hoogteblok"."px".($aantal <= 25 ? "; overflow-y: hidden" : "")."'> <table cellpadding='0' cellspacing='0'> <tr> <td class='CodeblokRegels' style='height: $hoogteregels"."px; width: $breedte"."px'> <code>"; for($i = 1; $i <= $aantal; $i++) { $blok .= "$i<br>"; } $blok .= " </code> </td> <td class='CodeblokCode'> $gekleurd </td> </tr> </table> </div>"; return $blok; } function Tekst($waarde) { global $htmlentitiesTabel; $waarde = str_replace("§","&sect;",$waarde); preg_match_all("#\[code\](.*?)\[/code\](\r)?(\n)?#is", $waarde, $GeenSmilies['code']); preg_match_all("#\[php\](.*?)\[/php\](\r)?(\n)?#is", $waarde, $GeenSmilies['php']); foreach($GeenSmilies as $i => $code) { foreach($code[0] as $nr => $tekst) { $waarde = str_replace($tekst,"§".$i.$nr."§",$waarde); } } $waarde = htmlentities($waarde,ENT_QUOTES); } // Smilies vervangen // UBB-codes vervangen $waarde = nl2br($waarde); foreach($GeenSmilies as $i => $code) { foreach($code[1] as $nr => $tekst) { $waarde = str_replace("&sect;$i$nr&sect;",Kleuren($tekst),$waarde); } } $waarde = str_replace("&amp;sect;","&sect;",$waarde);
based on iNFNs
Output for 5.1.0 - 7.1.0
Notice: Undefined variable: waarde in /in/U62nS on line 68 Notice: Undefined variable: GeenSmilies in /in/U62nS on line 70 Warning: Invalid argument supplied for foreach() in /in/U62nS on line 70
Output for 5.0.4 - 5.0.5
Notice: Undefined variable: waarde in /in/U62nS on line 68 Warning: Invalid argument supplied for foreach() in /in/U62nS on line 70
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.0.3
Notice: Undefined variable: waarde in /in/U62nS on line 68 Warning: Invalid argument supplied for foreach() in /in/U62nS on line 70
Output for 4.3.11
Notice: Undefined variable: waarde in /in/U62nS on line 68