For those who "grew up" programming in a language without it, a Switch/Case statement might seem to be a bit foreign. When "transitioning" programmer brought code to a review, O.C. rejected it and requested that he use a switch statement instead of the numerous elseif blocks. The same programmer returned to the next day's code review but didn't quite seem to understand the finer points of the switch statement ...
switch ($_GET['action']) { default: if ($_GET['action'] == 'delete') { $editid = (int) $_GET['delete']; } elseif ($_GET['action'] == 'edit') { $editid = (int) $_GET['edit']; } /* ED: Snip */ elseif ($_GET['action'] == 'save') { $editid == (int) $_GET['save']; } else { $editid = (int) $_GET['id']; } break; }
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!