Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the PHP language resultantly C?

Ok: I edited my question: I heard somewhere that php language is written in C.

So what happens for example when you run a function in php such as date("Ymd"); or file_get_contents("file.txt");?

Does it translate that code to C and request to server, or does php do it?

And if it does translate it and request, that means basically it is C?

like image 931
avon_verma Avatar asked Jan 05 '11 03:01

avon_verma


3 Answers

That is incorrect.

If you mean the language PHP is implemented in, it is C, not C++; see the PHP wikipedia page, under Implementation Language.

That does not, however, mean that it "translates" code to C; PHP is an interpreted language.

While executing code, it does of course have to use functions written in C, since it is itself using C. However, no "translation" into C occurs; the code is simply parsed by the PHP language and the language then calls, itself, what is appropriate.

You might want to read more on interpreted languages, that should give you a better understanding.

like image 93
houbysoft Avatar answered Oct 12 '22 09:10

houbysoft


In any interpreted language the language syntax is just a wrapper for functions and constructs implemented in the language the interpreted language is written in.

like image 1
Achilles Avatar answered Oct 12 '22 08:10

Achilles


Original PHP is a very trivial interpreter which does not perform any code generation. But there is an alternative implementation, a PHP to C++ compiler HipHop:

https://github.com/facebook/hiphop-php

like image 1
SK-logic Avatar answered Oct 12 '22 08:10

SK-logic