3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $pos = 0; public $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")); var_dump(crlf("\r\n ")); var_dump(crlf("\r\r\n")); var_dump(crlf("\n\n")); var_dump(crlf("\n\n ")); var_dump(crlf("\r\n\n")); var_dump(crlf("\r\n\n ")); var_dump(crlf("\r\n8")); var_dump(crlf("\n")); var_dump(crlf("\n "));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property Foo::$current is deprecated in /in/2sZXr on line 10 bool(true) Deprecated: Creation of dynamic property Foo::$current is deprecated in /in/2sZXr on line 10 bool(false) Deprecated: Creation of dynamic property Foo::$current is deprecated in /in/2sZXr on line 10 bool(false) Deprecated: Creation of dynamic property Foo::$current is deprecated in /in/2sZXr on line 10 bool(true) Deprecated: Creation of dynamic property Foo::$current is deprecated in /in/2sZXr on line 10 bool(true) Deprecated: Creation of dynamic property Foo::$current is deprecated in /in/2sZXr on line 10 bool(true) Deprecated: Creation of dynamic property Foo::$current is deprecated in /in/2sZXr on line 10 bool(true) Deprecated: Creation of dynamic property Foo::$current is deprecated in /in/2sZXr on line 10 bool(true) Deprecated: Creation of dynamic property Foo::$current is deprecated in /in/2sZXr on line 10 bool(true) Deprecated: Creation of dynamic property Foo::$current is deprecated in /in/2sZXr on line 10 bool(false)

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:
49.9 ms | 403 KiB | 8 Q