Home > Back-end >  Does PHP initiates new object for each user
Does PHP initiates new object for each user

Time:09-17

I am sure some devs are bit confused about that does PHP initiates new object for each user visiting the site.

Eg: if 100 users shopping on e-commerce website, how many objects are creating during their visit

CodePudding user response:

Let me try to explain.

Whenever a browser calls an url like the one of your e-commerce website, a webserver is receiving the request and decides what to do with it. In this e-commerce case the request goes to something like the FastCGI Process Manager (FPM) which will handle the PHP part of request and returns the result to the webserver and back to the browser again.

The FPM starts a single session for every incoming request. If the browser receives an answer, the request were answered an the session that handled the request is gone.

Therefore, yes, if 100 people visiting your e-commerce shop even in parallel, you create 100 times objects since every request from the browser is handled by a single session.

  • Related