3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = "ab"; $s1 = "cAbfabe"; $s2 = $s1; do { $s2 = stristr($s2,$s); echo "s2: $s2\n"; $s3 = substr($s2,0,count($s)+1); echo "s3: $s3\n"; $s2 = substr($s2,count($s)+1); echo "s2: $s2\n"; echo "=======\n"; } while ($s2 != false);
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
s2: Abfabe Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/GhHra:9 Stack trace: #0 {main} thrown in /in/GhHra on line 9
Process exited with code 255.
Output for 8.0.0 - 8.0.9
s2: Abfabe Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, string given in /in/GhHra:9 Stack trace: #0 {main} thrown in /in/GhHra on line 9
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
s2: Abfabe Warning: count(): Parameter must be an array or an object that implements Countable in /in/GhHra on line 9 s3: Ab Warning: count(): Parameter must be an array or an object that implements Countable in /in/GhHra on line 11 s2: fabe ======= s2: abe Warning: count(): Parameter must be an array or an object that implements Countable in /in/GhHra on line 9 s3: ab Warning: count(): Parameter must be an array or an object that implements Countable in /in/GhHra on line 11 s2: e ======= s2: Warning: count(): Parameter must be an array or an object that implements Countable in /in/GhHra on line 9 s3: Warning: count(): Parameter must be an array or an object that implements Countable in /in/GhHra on line 11 s2: =======
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25
s2: Abfabe s3: Ab s2: fabe ======= s2: abe s3: ab s2: e ======= s2: s3: s2: =======

preferences:
247.41 ms | 404 KiB | 330 Q