Linux command line pass parameters execute PHP files regularly

Source: Internet
Author: User

Recently in a project, you need to pass the parameters in Linux to execute PHP files regularly, online query data, there is really relevant information, now organized as follows:

1.linux Execute PHP file
#{php Install bin path}  {php file path}  {requires parameter 1 parameter 2 parameter 3}
#各参数之间, separated by a space
#查看php安装bin路径 executable which php command /usr/bin/php /local/www/index.php 111 222333
2. Receiving Parameters

 In general, PHP receives the command line passed over the parameters, $argv save all the parameters of the array, $ARGC save the number of parameters (the form of passing parameters and shell script is a bit similar), if the command to execute:/usr/bin/php/local/www/ index.php 111 222 333, print the results as follows:

<? PHP // index.php File Print_r ($argv); Print_r ($argc);? >

<? PHP // the $ARGV is receiving an array  $argv=array(  ' 0 ' = '/local/www/index.php ',//file path  ' 1 ' =>111,  //First parameter  ' 2 ' =>222,  //second parameter  ' 3 ' =>333   //third parameter )//$ ARGC received is the number of parameters, this example returns: 4?>

For more information on PHP scheduled tasks, refer to taskphp

Linux command line pass parameters execute PHP files regularly

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.