There are index.php files, which contain code:
header("Location: /from_index.php"); # 重定向(from_index.php的文件位置在:/www/)
To join a timed task using CRONTAB-E:
*/5 9-23 * * * sleep 50 && php /www/index.php # php脚本的绝对路径
Will the code in the from_index.php be executed in such a structure?
I learned that if you write:
*/5 9-23 * * * sleep 50 && curl -L -e '; auto' http://127.0.0.1/index.php # http访问
Is able to execute the code in the from_index.php. But is it not efficient to use PHP commands?
Reply content:
There are index.php files, which contain code:
header("Location: /from_index.php"); # 重定向(from_index.php的文件位置在:/www/)
To join a timed task using CRONTAB-E:
*/5 9-23 * * * sleep 50 && php /www/index.php # php脚本的绝对路径
Will the code in the from_index.php be executed in such a structure?
I learned that if you write:
*/5 9-23 * * * sleep 50 && curl -L -e '; auto' http://127.0.0.1/index.php # http访问
Is able to execute the code in the from_index.php. But is it not efficient to use PHP commands?
Execution of PHP
1.cli way, directly with PHP script execution
php index.php
2. Through the server request CGI mode
curl -L http://127.0.0.1/index.php
The header function jumps, is the server responds to curl (the equivalent of a browser) to redirect, and then re-request the server
So the Php/www/index.php,header function does not work to jump to the index.php script file because it does not go through the server.
//index.phpheader("Location:demo.php");
//demo.phpecho "this is demo";
Request result diagram
Request graph received by the server
If you use curl, you need to turn on its redirect switch.
Curl can not use header
It is not possible to execute that php file directly in the code with the system invoke PHP command.
The first question, no,
Second, there will be no direct execution of the CLI with high performance