pocketmine\utils\Utils::getOS PHP Method

getOS() public static method

Returns the current Operating System Windows => win MacOS => mac iOS => ios Android => android Linux => Linux BSD => bsd Other => other
public static getOS ( $recalculate = false ) : string
return string
    public static function getOS($recalculate = false)
    {
        if (self::$os === null or $recalculate) {
            $uname = php_uname("s");
            if (stripos($uname, "Darwin") !== false) {
                if (strpos(php_uname("m"), "iP") === 0) {
                    self::$os = "ios";
                } else {
                    self::$os = "mac";
                }
            } elseif (stripos($uname, "Win") !== false or $uname === "Msys") {
                self::$os = "win";
            } elseif (stripos($uname, "Linux") !== false) {
                if (@file_exists("/system/build.prop")) {
                    self::$os = "android";
                } else {
                    self::$os = "linux";
                }
            } elseif (stripos($uname, "BSD") !== false or $uname === "DragonFly") {
                self::$os = "bsd";
            } else {
                self::$os = "other";
            }
        }
        return self::$os;
    }

Usage Example

Example #1
0
 public function run()
 {
     if ($this->readline) {
         readline_callback_handler_install("CS> ", [$this, "readline_callback"]);
         $this->logger->setConsoleCallback("readline_redisplay");
     }
     while (!$this->shutdown) {
         $r = [$this->stdin];
         $w = null;
         $e = null;
         if (stream_select($r, $w, $e, 0, 200000) > 0) {
             // PHP on Windows sucks
             if (feof($this->stdin)) {
                 if (Utils::getOS() == "win") {
                     $this->stdin = fopen("php://stdin", "r");
                     if (!is_resource($this->stdin)) {
                         break;
                     }
                 } else {
                     break;
                 }
             }
             $this->readLine();
         }
     }
     if ($this->readline) {
         $this->logger->setConsoleCallback(null);
         readline_callback_handler_remove();
     }
 }
All Usage Examples Of pocketmine\utils\Utils::getOS