3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function titleCase($string) { $len=strlen($string); $i=0; $last= ""; $new= ""; $string=strtoupper($string); while ($i<$len): $char=substr($string,$i,1); if (ereg( "[A-Z]",$last)): $new.=strtolower($char); else: $new.=strtoupper($char); endif; $last=$char; $i++; endwhile; return($new); }; echo titleCase("hello there, world!"); ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function ereg() in /in/m8nL6:10 Stack trace: #0 /in/m8nL6(20): titleCase('HELLO THERE, WO...') #1 {main} thrown in /in/m8nL6 on line 10
Process exited with code 255.
Output for 5.3.0 - 5.6.28
Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Deprecated: Function ereg() is deprecated in /in/m8nL6 on line 10 Hello There, World!
Output for 4.3.0 - 5.2.17
Hello There, World!