3v4l.org

run code in 300+ PHP versions simultaneously
<?php // déclaration de variables $MotsAccent = array(); $Tb = array(); // mes fonctions function accents($text) { $text = htmlentities($text); $text = htmlspecialchars_decode($text); return $text; } function rep_fr_htmlaccents($chaine) { $patterns = array('/&acirc;/','/&auml;/','/&aacute;/','/&agrave;/','/&ecirc;/','/&euml;/','/&eacute;/','/&egrave;/','/&ocirc;/','/&ouml;/','/&oacute;/','/&ograve;/','/&ucirc;/','/&uuml;/','/&uacute;/','/&ugrave;/','/&icirc;/','/&iuml;/','/&iacute;/','/&igrave;/','/&ccedil;/','/&aelig;/'); $rep = array('a','a','a','a','e','e','e','e','o','o','o','o','u','u','u','u','i','i','i','i','c','o'); return preg_replace($patterns, $rep, $chaine); } function IsPalindrome($MotTeste) { $MotOrigine = rep_fr_htmlaccents($MotTeste); $MotInverse = strrev($MotOrigine); If ($MotInverse === $MotOrigine) { return $MotTeste; } return ""; } // fin de mes fonctions ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;" /> <title>Palindromes</title> </head> <body> <?php //Début du programme $txt = fopen('palindromes.txt','r'); while ($line = fgets($txt)) { $mots=preg_split("/\W+/", $line); for ($i = 0; $i < count($mots); $i++) { if (strlen($mots[$i])>1) { $tef = accents($mots[$i]); array_push($MotsAccent, strtolower($tef)); } } } $MotsDedoubles = array_unique($MotsAccent); foreach($MotsDedoubles as $MotsDedouble) { if ($MotsDedouble!="") { $res = IsPalindrome($MotsDedouble); if ($res!="" && strlen($res)>1) { $Tb[] = $res; } } } echo count($Tb)." Palindromes trouv&eacute;s : <br/>"; for ($i = 0; $i < count($Tb); $i++) { echo $Tb[$i]."<br/>"; } ?> </body> </html>
Output for git.master, git.master_jit
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;" /> <title>Palindromes</title> </head> <body> Warning: fopen(): open_basedir restriction in effect. File(palindromes.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/etKJQ on line 42 Warning: fopen(palindromes.txt): Failed to open stream: Operation not permitted in /in/etKJQ on line 42 Fatal error: Uncaught TypeError: fgets(): Argument #1 ($stream) must be of type resource, bool given in /in/etKJQ:43 Stack trace: #0 /in/etKJQ(43): fgets(false) #1 {main} thrown in /in/etKJQ on line 43
Process exited with code 255.
Output for rfc.property-hooks
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;" /> <title>Palindromes</title> </head> <body> Warning: fopen(): open_basedir restriction in effect. File(palindromes.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/etKJQ on line 42 Warning: fopen(palindromes.txt): Failed to open stream: Operation not permitted in /in/etKJQ on line 42 Fatal error: Uncaught TypeError: fgets(): Argument #1 ($stream) must be of type resource, false given in /in/etKJQ:43 Stack trace: #0 /in/etKJQ(43): fgets(false) #1 {main} thrown in /in/etKJQ on line 43
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
40.33 ms | 401 KiB | 8 Q