In both cases the update is set for 1 second intervals. which is considered a better way of doing it. The alternative is to get the browser to do it for you, something like this So if you wanted the "time" to update, you would have to keep pressing the browser refresh button to run the file again and again. You can see this more clearly by adding the PHP time() function to HelloWorld.php:. The PHP code will only run once, but each time you refresh your browser it will run again. If you save this file on your server as (say) HelloWorld.php when you point your remote web browser at it, it will simple return the string: Hello world!
This definition is important, because a simple PHP file will generally load when you point your web browser at it, run its code, and then stop.Ĭonsider this simple "Hello world" example This means it executes (runs) on a server while allowing some degree of interaction with the client, which is most often your computer web browser.
This server is also being used to automatically control a light outside the back of the house, and to monitor temperatures and graph the readings. I also installed wiringPi and configured the system in order to be able to access and control the gpio. My Raspberry Pi server is using lightpd as configured in this earlier post. What I've come up with is a simple file using HTML and a few lines of PHP code. I found a bit of time this week, so decided to try making a minimal PHP program to control the Pi gpio from a remote computer or phone. When I setup my Raspberry Pi server 8 months ago, one of its potential uses was for me to play with PHP and hopefully learn more about this language.