Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does PHP actually work? [closed]

Tags:

php

internals

Is there some guide out there that describes how the PHP internals?

  • How files are loaded (required, included)?
  • How they are parsed and executed?
  • How memory is allocated?
  • How objects are created/destroyed?
  • How external modules are loaded?
  • How the stack/heap works?
  • How opcode caching actually work?
  • Common hacks and performance tips?
like image 954
Kay Pale Avatar asked Dec 20 '10 19:12

Kay Pale


People also ask

How does PHP work behind the scenes?

PHP is an interpreted language. This means that you will write code statements (lines of code) and when a page is requested, the PHP interpreter will load your PHP code, parse it and then execute it. This differs from other languages, such as Java or C#, where the source code is compiled and then executed.

How does a PHP file end?

In PHP, statements are terminated by a semicolon (;) like C or Perl. The closing tag of a block of PHP code automatically implies a semicolon, there is no need to have a semicolon terminating the last line of a PHP block.

What is closure in PHP and why does it use use identifier?

The closure is a function assigned to a variable, so you can pass it around. A closure is a separate namespace, normally, you can not access variables defined outside of this namespace. There comes the use keyword: use allows you to access (use) the succeeding variables inside the closure.

What is the closure in PHP?

A closure is an anonymous function that can access variables imported from the outside scope without using any global variables. Theoretically, a closure is a function with some arguments closed (e.g. fixed) by the environment when it is defined. Closures can work around variable scope restrictions in a clean way.


2 Answers

Sounds to me like you're you should look for resources on PHP Internal development. Looking for this information elsewhere will be really scattered.

I suggest picking up a PHP Core development book from your local book store and giving it a read. PHP.net has an underdeveloped beginners reference if you wanted to start there.

like image 64
Craige Avatar answered Oct 13 '22 23:10

Craige


This excellent although somewhat outdated book by Sara Golemon has answers to the most of your questions. Otherwise, the best way to learn php internals is to compile a debug version of it and run it step by step under a debugger. I did it once and it was an exciting experience.

like image 37
user187291 Avatar answered Oct 13 '22 22:10

user187291