How can one properly navigate and reference file paths when executing shell scripts with PHP on a server setup with multiple directories?

When executing shell scripts with PHP on a server setup with multiple directories, it's important to properly navigate and reference file paths to ensure the scripts can locate the necessary files. One way to do this is by using the `__DIR__` magic constant in PHP to get the directory of the current script and then construct the full path to the file you want to execute. This helps in creating a dynamic and reliable way to reference files regardless of the server setup.

// Get the directory of the current script
$scriptDir = __DIR__;

// Construct the full path to the shell script file
$shellScriptPath = $scriptDir . '/path/to/your/shell/script.sh';

// Execute the shell script using the full path
$output = shell_exec($shellScriptPath);

// Output the result
echo $output;