What is the best practice for determining the path to PHP in a shell script?

When writing a shell script that needs to execute PHP code, it's important to determine the path to the PHP executable on the system. One common approach is to use the `which` command to locate the PHP binary. This command searches for the specified executable in the directories listed in the `PATH` environment variable. ```bash #!/bin/bash # Find the path to the PHP executable PHP_PATH=$(which php) # Check if PHP is installed if [ -z "$PHP_PATH" ]; then echo "PHP is not installed on this system." exit 1 fi # Use the PHP executable to run a PHP script $PHP_PATH /path/to/your/php/script.php ```