3v4l.org

run code in 300+ PHP versions simultaneously
<?php // camel case the class name class Smth { // changed the static class variables to constants const MARK_UNDEFINED = 'Undefined'; const MARK_F = 'ECTS-F'; const MARK_FX = 'ECTS-FX'; const MARK_E = 'ECTS-E'; const MARK_D = 'ECTS-D'; const MARK_C = 'ECTS-C'; const MARK_B = 'ECTS-B'; const MARK_A = 'ECTS-A'; // changed the protected method to public(no discernable reason to make it protected) // changed the function name to camel case public function getEctsMark($rate, $current, $examRate) { // moved this here to save us going through 2 if statements if($current > 0 && $examRate < 22) { return self::MARK_FX; } // the rest is the same as it was originally. $color = self::MARK_UNDEFINED; if ($current > 0) { $percent = $rate / $current; if ($percent < 0.31) { $color = self::MARK_F; } elseif ($percent < 0.60) { $color = self::MARK_FX; } elseif ($percent < 0.65) { $color = self::MARK_E; } elseif ($percent < 0.71) { $color = self::MARK_D; } elseif ($percent < 0.85) { $color = self::MARK_C; } elseif ($percent < 0.95) { $color = self::MARK_B; } else { $color = self::MARK_A; } } return $color; } }
Output for git.master, git.master_jit, rfc.property-hooks

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:
24.69 ms | 405 KiB | 5 Q