PHP language specification?
Asked Answered
S

7

24

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?

Social answered 13/1, 2011 at 12:40 Comment(1)
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.Elkeelkhound
C
20

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.

Chitchat answered 30/7, 2014 at 21:21 Comment(0)
S
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

Stradivari answered 13/1, 2011 at 13:2 Comment(3)
In order to have a language specification, we'd need significantly more than a grammar.Agee
Artefacto is right. A lot of topics, which wouldn't require to know the grammar imho could/should be covered...Social
@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.Stradivari
S
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.)

Scintillometer answered 25/1, 2011 at 12:5 Comment(0)
A
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

Arachnoid answered 31/7, 2014 at 8:11 Comment(0)
C
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.

Corves answered 31/7, 2014 at 8:13 Comment(0)
T
0

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

Towhaired answered 13/1, 2011 at 12:45 Comment(0)
S
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.

Seiter answered 13/1, 2011 at 12:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.