What are common methods to execute Linux commands in PHP, specifically for Raspberry Pi GPIO control?

To execute Linux commands in PHP for Raspberry Pi GPIO control, you can use the `shell_exec()` function. This function allows you to run shell commands and get the output. You can use it to interact with the GPIO pins on the Raspberry Pi by running commands like `gpio read` or `gpio write`.

// Example code to read from GPIO pin 4
$output = shell_exec("gpio read 4");
echo "GPIO pin 4 value: " . $output;

// Example code to write to GPIO pin 4
shell_exec("gpio mode 4 out");
shell_exec("gpio write 4 1");
echo "GPIO pin 4 set to HIGH";