In PHP, the php_uname() function is a very practical function that returns the complete information of the current operating system. This function allows you to obtain the system name, version, and other details. It is usually used for debugging, diagnosing, and obtaining system-level information.
The php_uname() function returns a string about the operating system, and the content of the string depends on the operating system type. You can choose to call it without parameters, or specify parameters to get more specific information.
string php_uname ([ string $mode = "a" ] )
$mode : This parameter is optional. You can use the following mode to get different operating system information:
'a' : By default, return system name, host name, operating system version and schema information.
's' : Returns only the operating system name.
'n' : Returns the host name of the computer.
'r' : Returns the version of the operating system.
'v' : Returns the version and patch level of the operating system.
'm' : Returns the machine type (hardware architecture).
If the $mode parameter is not specified, all information will be returned by default.
By default, calling php_uname() will return detailed information including operating system name, host name, operating system version, etc.
<?php
echo php_uname();
?>
Example output result:
Linux servername 4.15.0-45-generic #48-Ubuntu SMP Thu Jan 17 15:10:52 UTC 2019 x86_64
If you only care about the name of the operating system, you can use the pattern 's' .
<?php
echo php_uname('s');
?>
Example output result:
Linux
To get the host name (computer name), you can use the mode 'n' .
<?php
echo php_uname('n');
?>
Example output result:
servername
If you need the version information of the operating system, you can use the mode 'r' .
<?php
echo php_uname('r');
?>
Example output result:
4.15.0-45-generic
If you need more detailed OS version information, including patch level, you can use the mode 'v' .
<?php
echo php_uname('v');
?>
Example output result:
#48-Ubuntu SMP Thu Jan 17 15:10:52 UTC 2019
If you need to query the system's hardware architecture type (such as x86_64), you can use the pattern 'm' .
<?php
echo php_uname('m');
?>
Example output result:
x86_64
By using the php_uname() function, you can easily obtain various information about the operating system. You can choose different modes according to your needs to obtain different system details. This is very helpful for debugging, monitoring, and diagnosing problems.
If you use the URL in the code, you can replace the domain name part of the URL with m66.net . For example:
http://m66.net/api/data