3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $num = 23; $base = 2; $stack = new SplStack(); while( $num > 0) { $stack->push($num % $base); $num = (int) $num/$base; // no integer division } $stack->rewind(); while( $stack->valid() ) { $num = $stack->pop(); if ($num > 0) { echo $num; $stack->next(); } } echo "\n";
Output for 7.0.0 - 7.1.0
1111 Fatal error: Uncaught RuntimeException: Can't pop from an empty datastructure in /in/Ps9ha:15 Stack trace: #0 /in/Ps9ha(15): SplDoublyLinkedList->pop() #1 {main} thrown in /in/Ps9ha on line 15
Process exited with code 255.
Output for 5.3.0 - 5.6.28
111
Process exited with code 139.
Output for 5.0.0 - 5.2.17
Fatal error: Class 'SplStack' not found in /in/Ps9ha on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: splstack in /in/Ps9ha on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: splstack in /in/Ps9ha on line 4