PHP call function continusly

  gpio, php, raspberry-pi

I’m not very good at PHP and I have a problem.

This is my Code:


    echo "PHP WORKS!";


    exec("echo 17 > /sys/class/gpio/export");

    exec("echo in > /sys/class/gpio/gpio17/direction");


    $button_state =  exec("cat /sys/class/gpio/gpio17/value");

    echo $button_state;



It’s embeded in a html page.

The $button_state detects a gpio hardware button on a Raspberry Pi.
Its this line:

$button_state = exec("cat /sys/class/gpio/gpio17/value"); and
echo $button_state;

At the moment, if i press the button and reload the page, it detects 1.
What i want is that i can press the button and it shows me that the button is pressed, but without reloading. I want it to continusly check the state.. But the rest of the website should function at the same time!

How can I do this?
Thaks for your help!

Source: Ask PHP