: This article mainly introduces that, in the case of APP_DEBUGfalse, the CLI and WEBSITE will share the same ~ Runtimephp explain solves the problem of Compile. if you are interested in the PHP Tutorial, refer to it. If TP is used
define('APP_DEBUG',false);
Will generate./Runtime /~ Runtime. php stores the file, and the file will be processed every time it is used.
However, if a project uses CLI again, the./Runtime /~ The runtime. php file is the same as the website file, and the./Runtime/~ generated by the cli /~ The runtime. php file lacks some definition, such
If (! IS_CLI) {// current file name if (! Defined ('_ PHP_FILE _') {if (IS_CGI) {// CGI/FASTCGI mode $ _ temp = explode ('. php ', $ _ SERVER ['php _ SELF']); define ('_ PHP_FILE _', rtrim (str_replace ($ _ SERVER ['http _ host'], '', $ _ temp [0]. '. php '),'/');} else {define (' _ PHP_FILE _ ', rtrim ($ _ SERVER ['script _ name'], '/') ;}} if (! Defined ('') {// the root directory of the website URL if (strtoupper (APP_NAME) = strtoupper (basename (dirname (_ PHP_FILE _)))) {$ _ root = dirname (_ PHP_FILE _);} else {$ _ root = dirname (_ PHP_FILE _);} define ('', ($ _ root = '/' | $ _ root = '\\')? '': $ _ Root);} // supported URL mode define ('URL _ common', 0); // Normal mode define ('URL _ pathinfo ', 1); // PATHINFO mode define ('URL _ rewrite', 2); // REWRITE mode define ('URL _ compat', 3); // Compatible Mode}
The first solution is to change IS_CLI to 0.
define('IS_CLI',PHP_SAPI=='cli'? 1 : 0);
Change
define('IS_CLI',0);
But the problem has not been solved. it is actually defined (''), but
= .;
In website mode, = "";
Their _ PHP_FILE _ is also different. Although the code is the same.
Therefore, this solution is not feasible.
In the second solution, cli and website use two different runtime cache files.
Add the keyword in the index. php file.
$is_cli = PHP_SAPI=='cli' ? 1 : 0;if (!APP_DEBUG && $is_cli) {define('RUNTIME_FILE','./Runtime/~runtime_cli.php');}
In this way, using their own runtime files in different modes will not cause sudden bursts. Perfect solution!
The above describes that in the scenario where TP is APP_DEBUG = false, CLI and WEBSITE will share the same ~ Runtimephp explain the problem solving method, including some content, and hope to be helpful to friends who are interested in PHP tutorials.