PHP script #!/usr/bin/env php notation benefits

Source: Internet
Author: User
Tags php script

The first line of the scripting language is to point out that you want the code in your file to run it with what executable program.
For example, the first line of the PHP script can be written in the following formats
#!/usr/bin/php
#!/usr/bin/env PHP
#!/usr/bin/env-s-p/usr/local/bin:/usr/bin PHP
#!/usr/bin/env-s-p/usr/local/bin:/usr/bin:${path} PHP

#!/usr/bin/env the benefits of PHP notation
The main purpose of this writing is to make your program applicable on different systems.

Whether your PHP is in/usr/bin/php or/usr/local/bin/php
#!/usr/bin/env PHP will automatically look for PHP in the directory defined in your user's path variable.

Plus-P parameter use to specify some directories to find PHP this program
#!/usr/bin/env-s-p/usr/local/bin:/usr/bin PHP's role is to find PHP in the/usr/local/bin and/usr/bin directories.

To make the program more extensible, you can write the following code:
#!/usr/bin/env-s-p/usr/local/bin:/usr/bin:${path} PHP
#!/usr/bin/env-s-p/usr/local/bin:/usr/bin:${path} perl
(no spaces between-s-p)
It will also look in the directory defined in the path variable, in addition to the two directory searches.

#!/usr/bin/php written #!/usr/bin/env PHP would be better, of course #!/usr/bin/env-s-p/usr/local/bin:/usr/bin:${path} PHP
The general use of #!/usr/bin/env PHP This writing can be compatible with most servers.

In the same vein, the Python script begins with:

#!/usr/bin/env python

PHP script #!/usr/bin/env The benefits of PHP notation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.