例如thinkphp程序中有一个class,它有一个属性为获取用户的referrer
if($_SERVER['HTTP_REFERER']==null){ $visitor_info.='&referrer='.'empty'; }else{ $visitor_info.='&referrer='.$_SERVER['HTTP_REFERER']; } $this->visitor_info=$visitor_info; //一个属性为获取用户的referrer
当同时有多个用户访问时,每个用户都有一个对应不冲突的 $this->visitor_info 是吗?
请问 并发访问不冲突,背后的原理是什么??
是不是每个用户访问时,都会在内存中划一块区域保存对应的引用??
Generally speaking, when a user establishes a connection access, the server will open a new process to serve the request. In this process, the PHP interpreter will read the contents of the PHP file and instantiate an object. This object will have a Reference, when the request ends, all data is recycled, and the reference no longer exists.
That is, when each user accesses, the program enters the memory one by one and is processed by the CPU one by one. This should be related to CPU mechanism and memory-related knowledge. It's not a PHP problem. After a program is executed, there must be a result. Apache will return it after getting the result.
Because php is in multi-process mode. . When accessing, each user is an independent process space