What is the correct way to pass a variable from a shell script to a PHP script?

To pass a variable from a shell script to a PHP script, you can use command line arguments. In the shell script, you can call the PHP script with the variable as an argument. In the PHP script, you can access the passed variable using the $argv array.

// shell script (passing variable 'example_var')
// ./script.sh example_var

// PHP script
<?php
$variable = $argv[1]; // access the passed variable
echo "Passed variable: " . $variable;
?>