Can I turn off a computer using a PHP script?
Can I turn Off computer using PHP script
Collapse
X
-
You can turn off the server computer, sure. Just use the exec function to execute the shutdown command for your OS. (The exact command varies between OSs).
For example, for a Linux server, you could do:
[code=php]exec("shutdown -P now");[/code]
This, obviously, requires that PHP (or Apache, if PHP is run as an Apache module) is run by a user that is allowed to use that command. If not, you will not be able to do this.
If you are trying to shut down the computer's of a client (website visitor) then no, you can not. It's just basic security.
Comment