This issue came to hit me this morning when looking up info on class constants. The current PHP documentation located at http://us2.php.net/manual/en/language.oop5.constants.php has code displayed that doesn’t work. Specifically the concept of
$obj = new myObject(); echo $obj::constantName;
This simply doesn’t work in PHP 5.2.4 (and I assume 5.2.5). You get the dreaded “unexpected T_PAAMAYIM_NEKUDOTAYIM” message (well, it’s not ‘dreaded’ but you know what I mean!).
Above the code block that shows that type of code, there’s a reference to PHP 5.3.0 which seems to have nothing to do with the code sample below it. I can only assume that this behaviour will work in PHP 5.3.0.
My issue is not with the language itself (this time!) but how this sort of documentation is handled. Updating public documentation well ahead of a release creates confusion. What would help immensely is to have documentation that was archived to specific versions, such that I could put a /5.2.4 in the URL and make sure I was seeing documentation that matched my version. As it stands now, there’s no consistency. I do appreciate some of the messages in docs that say ‘before version X, foo() behaved like Y’ and similar messages. They let you know that if you’re seeing different behaviour, there’s a reason. With this current class constants page, there’s no indication that the given code samples will break in all current versions of PHP and are (I’m theorizing) intended for a future version.
Maybe I’m missing something very obvious – are there archived versions of the documentation already that I’m just missing?
Other possibility – this works in PHP 5.2.5, but not 5.2.4. Given how major changes in underlying functionality sometimes seem to crop up in minor point releases, this would not surprise me. Is this the case? Am I just WAY behind the times using 5.2.4? There are no references to this behaviour change in the 5.2.5 release notes, so I assume it didn’t change in 5.2.5.
I'm currently working on a book for web freelancers, covering everything you need to know to get started or just get better. Want to stay updated? Sign up for my mailing list to get updates when the book is ready to be released!