TP in the case of APP_DEBUG = false, CLI and WEBSITE will share the same ~ Runtimephp releases the problem solving method of failover.

Source: Internet
Author: User
: 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.

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.