get system platform in php

To get the system platform in PHP, you can use the php_uname function. This function returns a description of the operating system PHP is running on. Here's an example:

main.php
$platform = php_uname();
echo $platform;
41 chars
3 lines

This will output a string with information about the operating system, including the OS name, version, and architecture.

If you want to get specific information about the operating system, such as the OS name or version, you can use the PHP_OS constant or the posix_uname function. Here's an example that uses PHP_OS:

main.php
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    echo 'Windows';
} else {
    echo 'Unix-based';
}
104 chars
6 lines

This will output either "Windows" or "Unix-based", depending on the operating system PHP is running on.

related categories

gistlibby LogSnag