tags:

views:

115

answers:

3

This may sound like a stupid question but I'm a beginner not just to PHP but to programming in general, so in that context:

What language are inbuilt PHP functions written in?

For example the inbuilt function "date("l")" when echoed will dislay the current day on the browser. But obviously this isn't done by magic, some one had to write this function, I am merely calling it.

A function as I understand it, is a way to contain a lot of PHP commands inside one call, and all those containing commands are written in PHP as well. But when it comes to the inbuilt function libraries, are these written in PHP or some other language?

And secondly, I have been told that the core of PHP 5 is written in C++ is this true?

+2  A: 

PHP was written in C. Any language above machine code for the specific processor architecture is written in a lower-level language. These abstractions into higher-level languages are an effort to make programming simpler and more productive.

Zurahn
Okay so the core of PHP is in C, does this mean the functions are as well? Am I to consider the functions as part of the core?
Waren
"Any language above machine code for the specific processor architecture is written in a lower-level language". Not exactly. I believe C compilers and libraries are written in C, and Java and most of its libraries are written in java. Once you've built the first compiler, there's nothing preventing you from implementing the rest of the language in the language itself.
Frank Farmer
@Frank: Yes, I could have phrased that a bit better. Good clarification.
Zurahn
+5  A: 

PHP has been written in what I call the mother of languages ^C^

Sarfraz
That includes the interpreter, core libraries, and most, if not all extensions. You can browse the source here: http://cvs.php.net/viewvc.cgi/
Frank Farmer
@Frank Farmer: great, thanks for that link :)
Sarfraz
Thanks for verifying that.
Waren
@Waren: You are welcome :)
Sarfraz
+1  A: 

PHP is in C, parts of it and most of is extension are written in C++.

Itay Moav
the part "most of is extension are written in C++" is wrong, *some* extensions are written in C++, most are written in C. AFAIK, no extension bundled with PHP is written in C++; some PECL extensions contain C++ code (see http://svn.php.net/viewvc/pecl/win32std/trunk/). an example of a fairly mainstream PHP extension that's all C++ would be the `sqlsrv` SQL Server driver.
just somebody
well...At least what we wrote at Zend is all CPP.
Itay Moav