3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); function getCollectionParentIDFromChildID($cID) { if(is_numeric($cID)) { if($cID > 1) { return '1'; } if($cID == 1) { return '0'; } } return null; } function populateParentIDArray_current($cID) { global $cParentIDArray; $cParentID = getCollectionParentIDFromChildID($cID); if($cParentID > -1) { if(!in_array($cParentID, $cParentIDArray)) { $cParentIDArray[] = $cParentID; } populateParentIDArray_current($cParentID); } } function populateParentIDArray_new($cID) { global $cParentIDArray; $cParentID = getCollectionParentIDFromChildID($cID); if(is_numeric($cParentID)) { if(!in_array($cParentID, $cParentIDArray)) { $cParentIDArray[] = $cParentID; } if($cParentID > 0) { populateParentIDArray_new($cParentID); } } } function runTest($cID) { global $cParentIDArray; echo "Test case for "; var_dump($cID); $cParentIDArray = array(); populateParentIDArray_current($cID); ob_start(); var_dump($cParentIDArray); $current = ob_get_contents(); ob_end_clean(); $cParentIDArray = array(); populateParentIDArray_new($cID); ob_start(); var_dump($cParentIDArray); $new = ob_get_contents(); ob_end_clean(); if($current === $new) { echo "Passed. Result: ", $current; } else { echo "###ERROR\nCURRENT: ", $current, "\nNEW: ", $new, "\n"; } echo "\n\n"; } runTest('3'); runTest(3); runTest('1'); runTest(1); runTest('0'); runTest(0); runTest('-1'); runTest(-1); runTest(null); runTest(''); runTest(false);
Output for git.master, git.master_jit, rfc.property-hooks
Test case for string(1) "3" Passed. Result: array(2) { [0]=> string(1) "1" [1]=> string(1) "0" } Test case for int(3) Passed. Result: array(2) { [0]=> string(1) "1" [1]=> string(1) "0" } Test case for string(1) "1" Passed. Result: array(1) { [0]=> string(1) "0" } Test case for int(1) Passed. Result: array(1) { [0]=> string(1) "0" } Test case for string(1) "0" Passed. Result: array(0) { } Test case for int(0) Passed. Result: array(0) { } Test case for string(2) "-1" Passed. Result: array(0) { } Test case for int(-1) Passed. Result: array(0) { } Test case for NULL Passed. Result: array(0) { } Test case for string(0) "" Passed. Result: array(0) { } Test case for bool(false) Passed. Result: array(0) { }

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:
41.34 ms | 402 KiB | 8 Q