PHP language specification?

自闭症网瘾萝莉.ら 提交于 2019-11-30 04:41:50

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.

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

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.)

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

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.

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

deepcell

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!