How can the CLI version of PHP be correctly referenced to match the version used by the host for Drupal development?

When developing a Drupal site, it is important to ensure that the CLI version of PHP matches the version used by the host to prevent compatibility issues. To correctly reference the CLI version of PHP, you can specify the full path to the PHP executable in your command line scripts or use a shebang line at the beginning of your scripts to specify the PHP version to be used.

#!/usr/bin/env php