23

I know there is an official document for Java (JLS), I'd like to know if it's also the case of PHP language. I found the "Language Reference" section on the PHP manual, but it doesn't look as detailed as the JLS.

The thing is I have a good practical knowledge of PHP but I'm miserably clueless about what really happens under the hood.

If there isn't any official document, could you recommend me some good books to read?

user229044
  • 232,980
  • 40
  • 330
  • 338
fbiville
  • 8,407
  • 7
  • 51
  • 79
  • I've always found the online PHP manual to be an excellent reference. You may have a point though; I can't think of a directly similar document in PHP to the Java one. – Spudley Jan 13 '11 at 12:46

7 Answers7

18

An initial draft specification for the PHP language has now been announced. The introduction of the specification reads as follows:

This specification is intended to provide a complete and concise definition of the syntax and semantics of the PHP language, suitable for use by the following:

  • Implementers of a PHP compiler
  • Implementers of a test suite for the PHP language
  • Programmers writing PHP code

For now, the runtime library has been excluded, as that is documented at www.php.net. As such, all forward references to library facilities have placeholders of the form (§xx).

See also the latest version of the draft.

Community
  • 1
  • 1
Smi
  • 13,850
  • 9
  • 56
  • 64
8

There was a discussion about that topic on the internals mailing list not too long ago.

You can check the status there.

Starting Post: http://marc.info/?l=php-internals&m=129379585417113&w=2

Dear internals

After enviously looking at pythons grammar (http://docs.python.org/dev/reference/grammar.html) I keep feeling that PHP is missing out on a lot of interesting meta projects by not having an official EBNF. [...]

and one hopefully helpfull follow up describing some grammar:

http://marc.info/?l=php-internals&m=129387252319019&w=2

And Stats take in the matter:

http://marc.info/?l=php-internals&m=129383062812273&w=2

Hi! [...]

You're not the only one thinking about it. But so far nobody moved from thinking about it to actually doing it :)

-- Stanislav Malyshev, Software Architect

Community
  • 1
  • 1
edorian
  • 38,542
  • 15
  • 125
  • 143
  • 1
    In order to have a language specification, we'd need significantly more than a grammar. – Artefacto Jan 13 '11 at 13:27
  • Artefacto is right. A lot of topics, which wouldn't require to know the grammar imho could/should be covered... – fbiville Jan 14 '11 at 13:13
  • @Rofl: Yeah, my post way directed at "state of the "let's create a language spec for php" discussion. As there is only 1 pretty old (and for a good part outdated) book about php core and some slideshows of talks about it. – edorian Jan 14 '11 at 15:08
4

From what I read on Wikipedia, both PHP and Perl5 have in common that they are "languages" which are entirely defined through one single implementation. The language is precisely whatever the interpreter does. Neither are like C or C++ or Java or ECMAScript, which are standardised languages with many different implementations. (Apparently Perl6 will be different and actually have a specification. No idea of PHP will also one day make this step.)

Jimmy R
  • 41
  • 1
2

In this post, the HHVM Community announced a specification for PHP: http://hhvm.com/blog/5723/announcing-a-specification-for-php

It's now located in the following Github repo: https://github.com/php/php-langspec

Marc Juchli
  • 2,240
  • 24
  • 20
1

For the formally inclined, a detailed (executable) semantics of PHP is available at www.phpsemantics.org and will be presented tomorrow at the ECOOP 2014 conference in Sweden.

0

From this (dated) weblog post it appears that there is no specification for PHP like there is one for Java.

Richard Tuin
  • 4,484
  • 2
  • 19
  • 18
0

PHP and Java are different languages for different purposes, of course the documentation do not follow the same standard. I think php.net is the best place to find whatever you want, also have good books, it all depends what about your needs.

Java also has great books, and of course the Java Specification.

PHP does not have an specification, but have a tech manual of it and plenty of examples. What more do you need? Perhaps an specific book, try to look for Wiley Publishing they print books about PHP and other languages.

halfer
  • 19,824
  • 17
  • 99
  • 186
devasia2112
  • 5,844
  • 6
  • 36
  • 56