Shutdown computer using PHP Script

0
394

Welcome Back to Shortlearner.com. today we will see how to Shutdown computer using PHP Script .

shutdown computer using php script

As we all know PHP is server side scripting language and with the help of PHP script we are perform some shell command also.

with the help of the shell command we will shutdown our computer system. so in this post we will wrap the shell script in our php tags.

abd whenever user run this php script , his system will automatically shut down after 45 seconds, because in the below code we set the timing of executing of shell script.

if you want to change the timing of the process you can easily change.
in the below code we will using some predefined PHP function that will help us to shutdown the system.

PHP (hyper text pre processor ) provide us some predefined  functions that will help us to shutting down any machine with in a seconds.

the first function is system() function.

second is the exec(). 

and the last one is shell_exec() function.

<?php system('shutdown -s -t 45'); //45 means shutdown after 45 seconds ?>
 
 OR 

<?php exec('shutdown -s -t 45'); ?>

OR 

<?php shell_exec('shutdown -s -t 45'); ?>

In the above scripts we put the time when the system will restart after hitting the script.

Also Read : How to check file size using php

Send mail without SMTP Authentication in php

Print numbers from 1 to n without loop in php