3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Shipping { /** * @return integer The minimum number of boxes needed to hold a given number of items */ public static function minimalNumberOfPackages($items, $availableLargePackages, $availableSmallPackages) { $maxSize = 5; if ($items < $maxSize) return $items; if (($items - ($maxSize * $availableLargePackages + $availableSmallPackages)) > 0) return -1; $itemsNotHoldByMax = $items / 5; if ($itemsNotHoldByMax > $items) $itemsNotHoldByMax = $availableLargePackages; return $itemsNotHoldByMax + ($items - $maxSize * $itemsNotHoldByMax); } public static function minimalNumberOfBoxes2( $products, $availableLargeBoxes, $availableSmallBoxes) { if ($products < 5) return $products; if (($products - (5 * $availableLargeBoxes + $availableSmallBoxes)) > 0) return -1; $rl = $products / 5; if ($rl > $availableLargeBoxes) $rl = $availableLargeBoxes; return $rl + ($products - 5 * $rl); } } echo Shipping::minimalNumberOfPackages2(16, 2, 10);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined method Shipping::minimalNumberOfPackages2() in /in/6MW80:41 Stack trace: #0 {main} thrown in /in/6MW80 on line 41
Process exited with code 255.

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:
34.16 ms | 401 KiB | 8 Q