What is PHP core?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

abalfazl
Forum Commoner
Posts: 71
Joined: Mon Sep 05, 2005 10:05 pm

What is PHP core?

Post by abalfazl »

1-What is PHP core?
2-How does it work?
3-What is Zend engine?
4-Which language is used to build PHP core(For PHP 5) and zend engine?
5-What is relationship between C and PHP 5?
User avatar
Ragnis
Forum Commoner
Posts: 31
Joined: Thu Nov 13, 2008 12:35 pm
Location: Saaremaa, Estonia, Europe, Asia, Planet Earth, The Solar System, Milky way.

Re: What is PHP core?

Post by Ragnis »

5. PHP is written in C
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: What is PHP core?

Post by josh »

User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: What is PHP core?

Post by Eran »

As far as I can tell, it's written in C.
abalfazl
Forum Commoner
Posts: 71
Joined: Mon Sep 05, 2005 10:05 pm

Re: What is PHP core?

Post by abalfazl »

Again: What is PHP core and how does it work?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: What is PHP core?

Post by alex.barylski »

A quick checkout from SVN of 5.2:

Code: Select all

469317  ext             ansic=450035,sh=8399,php=7377,yacc=1483,tcl=1128, awk=860,pascal=35
63119   Zend            ansic=58435,lex=2296,php=1441,yacc=947
19304   main            ansic=19304
17619   sapi            ansic=16818,cpp=682,php=119
11522   top_dir         sh=8417,php=3105
3550    regex           ansic=3489,sh=61
3243    win32           ansic=2917,php=326
2677    TSRM            ansic=2652,sh=25
1681    build           sh=1534,awk=147
931     scripts         php=506,sh=387,awk=38
744     tests           php=671,perl=71,pascal=2
75      netware         ansic=75
64      pear            php=64


Totals grouped by language (dominant language first):
ansic:       553725 (93.24%)
sh:           18823 (3.17%)
php:          13609 (2.29%)
yacc:          2430 (0.41%)
lex:           2296 (0.39%)
tcl:           1128 (0.19%)
awk:           1045 (0.18%)
cpp:            682 (0.11%)
perl:            71 (0.01%)
pascal:          37 (0.01%)
PHP is indeed (excluding externals) 93.4% written in ANSI C. :)

Cheers,
Alex
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: What is PHP core?

Post by alex.barylski »

Again: What is PHP core and how does it work?
Your asking the wrong crowd, most of us are primarily interested in using PHP not building it. The architecture is complex and highly optimized. You could probably learn a great deal by sifting through the code, implementing some basic extensions, etc. I have Googled many times in the past and found very little on the subject so I suspect your in for the same ride.

So again, start Googling. ;)

Cheers,
Alex
ell0bo
Forum Commoner
Posts: 79
Joined: Wed Aug 13, 2008 4:15 pm

Re: What is PHP core?

Post by ell0bo »

The core of the code in written in C, however extensions and the like can be written in C++. The difference between to two, as far as this forum goes, is negligible.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: What is PHP core?

Post by alex.barylski »

The core of the code in written in C, however extensions and the like can be written in C++.
You might be bale to, but would it make sense to use C++? I recall the extension API having to confirm to a specific calling convention (which C++ could do) but then there is the issue of resolving the *this* pointer.

So the API would almost certaily have to be built as a C library and the implementation of each function could use objects internally, but at that point, I would just stick with C.

Cheers,
Alex
abalfazl
Forum Commoner
Posts: 71
Joined: Mon Sep 05, 2005 10:05 pm

Re: What is PHP core?

Post by abalfazl »

Your asking the wrong crowd, most of us are primarily interested in using PHP not building it. The architecture is complex and highly optimized. You could probably learn a great deal by sifting through the code, implementing some basic extensions, etc. I have Googled many times in the past and found very little on the subject so I suspect your in for the same ride.

Thanks for answer, But of course someone here work with PHP core and help me
ell0bo
Forum Commoner
Posts: 79
Joined: Wed Aug 13, 2008 4:15 pm

Re: What is PHP core?

Post by ell0bo »

PCSpectra wrote:
The core of the code in written in C, however extensions and the like can be written in C++.
You might be bale to, but would it make sense to use C++? I recall the extension API having to confirm to a specific calling convention (which C++ could do) but then there is the issue of resolving the *this* pointer.

So the API would almost certaily have to be built as a C library and the implementation of each function could use objects internally, but at that point, I would just stick with C.

Cheers,
Alex
I don't remember entirely how it works, it's been about two years since I looked into writing my own extension, but I know it involved C++, because at this point thinking in C terms (aka procedurally) instead of c++ (OO) makes my head hurt.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: What is PHP core?

Post by josh »

I have a book called "Extending & Embedding PHP". I didn't read it yet but the index implies the 'core' is related to the following topics: core globals, core php functions (error reporting, misc, open basedir, output, reentrancy safety, safe mode, startup/shutdown,string formatting).
abalfazl
Forum Commoner
Posts: 71
Joined: Mon Sep 05, 2005 10:05 pm

Re: What is PHP core?

Post by abalfazl »

How does PHP core work?

I want to know what happened behind. Please show me by a simple PHP code, What happened in PHP core when that code runs.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: What is PHP core?

Post by Jonah Bron »

abalfazl wrote:How does PHP core work?
Did you read the posts by everyone?
abalfazl wrote:... Please show me by a simple PHP code ...
It's not written in PHP, it's written in C.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: What is PHP core?

Post by josh »

I think he wants help visualizing the parse tree that the php core seems like it would have to build.
Post Reply