Page 1 of 1
What actually happens after php interpreter parses code?
Posted: Mon Mar 07, 2011 8:45 pm
by blacktie524
What actually happens in the background after php interpreter parses code that says, open a database connection, execute curl request, etc.? So when a php script is run and the php interpreter parses the script and finds code that says open a database connection and perform a query, how does this actually happen? What goes on in the background that actually fulfills this request and performs the communication with the database?
Re: What actually happens after php interpreter parses code?
Posted: Tue Mar 08, 2011 7:17 am
by Weirdan
After php script is read and tokenized it's compiled into intermediary representation called bytecode. Compiled bytecode is interpreted by Zend Engine. It may contain calls to any extension functions e.g. mysql_connect() - and whenever such call is met execution is transferred to the native code of the extension called. Usually (but not necessarily) extensions are just wrappers for some external library (like libmysql), and they pass the execution to the library code, which is responsible for whatever the library is doing, like establishing tcp connection to mysql server and talking to it following appropriate protocol.