note 113172 added to reserved.constants

From: Date: Sun, 08 Sep 2013 21:16:39 +0000
Subject: note 113172 added to reserved.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-196198@lists.php.net to get a copy of this message
Volker's getOS() function needs to have the order of cases changed in the switch statement since "darwin" contains "win", which means that both "windows" and "darwin" will return self::OS_WIN. I've moved the 'dar' case above the 'win' case: <?php class System { const OS_UNKNOWN = 1; const OS_WIN = 2; const OS_LINUX = 3; const OS_OSX = 4; /** * @return int */ static public function getOS() { switch (true) { case stristr(PHP_OS, 'DAR'): return self::OS_OSX; case stristr(PHP_OS, 'WIN'): return self::OS_WIN; case stristr(PHP_OS, 'LINUX'): return self::OS_LINUX; default : return self::OS_UNKNOWN; } } } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 108.29.25.237 ---- Manual Page -- http://php.net/manual/en/reserved.constants.php Edit -- https://master.php.net/note/edit/113172 Del: integrated -- https://master.php.net/note/delete/113172/integrated Del: useless -- https://master.php.net/note/delete/113172/useless Del: bad code -- https://master.php.net/note/delete/113172/bad+code Del: spam -- https://master.php.net/note/delete/113172/spam Del: non-english -- https://master.php.net/note/delete/113172/non-english Del: in docs -- https://master.php.net/note/delete/113172/in+docs Del: other reasons-- https://master.php.net/note/delete/113172 Reject -- https://master.php.net/note/reject/113172 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196198) next »