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?
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With