There is a function developed with the TP3.1 framework. After the calculation is completed, it is required to return {"status":0}
The final code is
<code> ini_set("max_execution_time", "800"); ... $data['status'] = 0; Log::write(json_encode($data),Log::DEBUG); echo json_encode($data); Log::write('echo success',Log::DEBUG);</code>
The running result is
<code>[ 2016-07-18T14:50:36+08:00 ] DEBUG: 运行时间:486.8268s [ 2016-07-18T14:50:36+08:00 ] DEBUG: {"status":0} [ 2016-07-18T14:50:36+08:00 ] DEBUG: echo success</code>
But the page does not have echo json_encode($data);
F12 check the http request and there is no return, but the calculation is completed, the code is basically pasted, as long as you delete some of the code that takes a long time to calculate, you can get the return value, but I have set max_execution_time
, and the calculation did not exceed the time
Reply content:
There is a function developed with the TP3.1 framework. After the calculation is completed, it is required to return {"status":0}
The final code is
<code> ini_set("max_execution_time", "800"); ... $data['status'] = 0; Log::write(json_encode($data),Log::DEBUG); echo json_encode($data); Log::write('echo success',Log::DEBUG);</code>
The running result is
<code>[ 2016-07-18T14:50:36+08:00 ] DEBUG: 运行时间:486.8268s [ 2016-07-18T14:50:36+08:00 ] DEBUG: {"status":0} [ 2016-07-18T14:50:36+08:00 ] DEBUG: echo success</code>
But the page does not have echo json_encode($data);
F12 check the http request and there is no return, but the calculation is completed, the code is basically pasted, as long as you delete some of the code that takes a long time to calculate, you can get the return value, but I have set max_execution_time
, and the calculation did not exceed the time
ini_set("max_execution_time", "800"); ... $data['status'] = 0; Log::write(json_encode($data),Log::DEBUG); echo json_encode($data); Log::write('echo success',Log::DEBUG); exit;//退出脚本
$data['status'] = 0;
echo 1;
Log::write(json_encode($data),Log::DEBUG);
echo 2;
echo json_encode($data);
echo 3;
Log::write('echo success',Log::DEBUG);
Try it like this and see if it runs here
Made ajax request? Browser F12 to see if the requested link was successful and if a reply was received. The information given is too little, please provide more details.
I don’t see any obvious problem. Is the timeout set for the request made using xhr? The return value is ignored because the calculation takes too long. By the way, it is recommended to add header('Content-Type: application/json');

DependencyinjectioninPHPisadesignpatternthatenhancesflexibility,testability,andmaintainabilitybyprovidingexternaldependenciestoclasses.Itallowsforloosecoupling,easiertestingthroughmocking,andmodulardesign,butrequirescarefulstructuringtoavoidover-inje

PHP performance optimization can be achieved through the following steps: 1) use require_once or include_once on the top of the script to reduce the number of file loads; 2) use preprocessing statements and batch processing to reduce the number of database queries; 3) configure OPcache for opcode cache; 4) enable and configure PHP-FPM optimization process management; 5) use CDN to distribute static resources; 6) use Xdebug or Blackfire for code performance analysis; 7) select efficient data structures such as arrays; 8) write modular code for optimization execution.

OpcodecachingsignificantlyimprovesPHPperformancebycachingcompiledcode,reducingserverloadandresponsetimes.1)ItstorescompiledPHPcodeinmemory,bypassingparsingandcompiling.2)UseOPcachebysettingparametersinphp.ini,likememoryconsumptionandscriptlimits.3)Ad

Dependency injection provides object dependencies through external injection in PHP, improving the maintainability and flexibility of the code. Its implementation methods include: 1. Constructor injection, 2. Set value injection, 3. Interface injection. Using dependency injection can decouple, improve testability and flexibility, but attention should be paid to the possibility of increasing complexity and performance overhead.

Implementing dependency injection (DI) in PHP can be done by manual injection or using DI containers. 1) Manual injection passes dependencies through constructors, such as the UserService class injecting Logger. 2) Use DI containers to automatically manage dependencies, such as the Container class to manage Logger and UserService. Implementing DI can improve code flexibility and testability, but you need to pay attention to traps such as overinjection and service locator anti-mode.

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
