3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { var $pos = 0; var $str; function Foo($str) { $this->__construct($str); } function __construct($str) { $this->str = $str; $this->current = $this->lookAhead(); } function isLineBreak() { if ("\r" !== $this->current && "\n" !== $this->current) { return false; } $char = $this->current; do { $brk = ("\n" === $char); $char = $this->lookAhead(); switch ($char) { case " ": return false; case "\n": if ($brk) { return true; } break; default: return $brk; } } while (true); } function lookAhead() { return mb_strcut($this->str, $this->pos++, 1); } } function crlf($str) { $foo = new Foo($str); return $foo->isLineBreak(); } var_dump(crlf("\r\n"));
Output for 4.3.0 - 4.4.9, 7.0.0 - 7.1.0
bool(true)
Output for 5.1.3 - 5.6.28
Strict Standards: Redefining already defined constructor for class Foo in /in/dqEYF on line 11 bool(true)
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/dqEYF on line 5 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/dqEYF on line 6 Strict Standards: Redefining already defined constructor for class Foo in /in/dqEYF on line 11 bool(true)