I came across a small need today.
How to display the server’s machine name in a web page,
In Ubuntu, just enter the command: uname -n to see (the same is true for Redhat),
So I wonder if php can directly call the shell command to perform this operation?
After checking the information,
I learned that there is indeed one, and there are several of them:
popen
fpassthru
shell_exec
exec
system
Read how to use it,
It seems that shell_exec is relatively simple. You only need to pass in the command as parameters,
And it directly returns the result after executing the command,
So I tried it:
< ?php
shell_exec('uname -n');
?>
Successfully displayed the machine name of the current server.
However, if it is a purchased server, the test may not be successful,
Because for security reasons, the server provider may disable some or all of them
http://www.bkjia.com/PHPjc/477863.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477863.htmlTechArticleI encountered a small need today. How to display the server’s machine name in a web page. In Ubuntu, just Enter the command: uname -n to see (the same is true for Redhat), so I wonder if php can directly...