php_uname() is a function in PHP that obtains operating system-related information. It returns a string containing the name, version of the operating system, and other related information. Different operating system information can be obtained by passing different parameters to the function. There are 5 types of parameters received by the php_uname() function, namely: a , s , r , v and m , and the functions of each parameter are different.
Below we will explain these parameters and their role in PHP.
If you pass a as parameter, the php_uname() function will return the full information of the operating system. This information includes the operating system name, version, kernel version, machine architecture, and host name.
For example:
echo php_uname('a');
Output example:
Linux server.example.com 4.15.0-45-generic #48-Ubuntu SMP Wed Apr 18 08:32:18 UTC 2025 x86_64
This will return information such as the name of the operating system (such as Linux ), the host name (such as server.example.com ), the kernel version number, the system architecture (such as x86_64 ), and so on.
If the s parameter is passed, php_uname() will only return the name of the operating system. For example:
echo php_uname('s');
Output example:
Linux
This will only return the name of the operating system, such as Linux or Windows NT .
Pass the r parameter, the php_uname() function will return the published version of the operating system. For example:
echo php_uname('r');
Output example:
4.15.0-45-generic
This is the kernel version number of the operating system.
If the v parameter is passed, php_uname() will return the specific version information of the operating system. This information includes the compiled version of the kernel, timestamp, etc.
For example:
echo php_uname('v');
Output example:
#48-Ubuntu SMP Wed Apr 18 08:32:18 UTC 2025
This output returns details of the operating system version, such as the kernel's compile date and time.
Finally, when passing the m parameter, php_uname() returns the machine architecture type. Common return values include x86_64 (64-bit architecture), i686 (32-bit architecture), etc.
For example:
echo php_uname('m');
Output example:
x86_64
This output shows the machine architecture type, usually 32-bit or 64-bit.
a : Returns the complete operating system information.
s : Returns the name of the operating system.
r : Returns the kernel version of the operating system.
v : Returns the version of the operating system.
m : Returns the machine architecture type.
Use these parameters to help developers obtain the operating system and architecture information of the running server, so as to make more appropriate judgments and optimizations during the development process.