I have an idea, and i have a single php local web page running on localhost
and i want to use GUI for 3 buttons : shut down , sleep and restart
Is PHP allows to me for these operations? Are there ready to write classes, methods in PHP?
If your Apache/PHP configuration is setup to allow the use of system
, then you can use that.
For *nix systems:
system('shutdown now'); // shutdown
// or
system('reboot'); // reboot
system('shutdown -r now'); // also reboot :)
For Windows:
system('shutdown -t -s 0'); // shutdown
// or
system('shutdown -r -t 0'); // reboot
More info here.
As far as sleep/standby on *nix is concerned, it varies a lot.
Note: You can also use shell_exec()
or exec()
.
EDIT:
Per user1597430's comment, in *nix systems you can pass the -h
(halt) option which will essentially shut down and halt the CPUs but not disconnect the main power.
system('shutdown -h now'); // shutdown and halt
system('shutdown -P now'); // shutdown and power off
Server fault has some great answers here about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With