How to get the OS on which PHP is running?
You can use the php_uname()
function to get the operating system on which PHP is running. This function returns a string containing information about the operating system, such as the machine type, release, and version. Example:
Watch a video course
Learn object oriented PHP
This will output something like "Windows NT XAMPP 7.4.14" or "Linux server 4.15.0-142-generic #146-Ubuntu SMP Mon Apr 12 18:48:51 UTC 2021" It's worth noting that this will only give information about the server where the PHP code is running, if you want to know the OS of the client machine, you will need to use javascript or other client-side language to access that information.