php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42313 Example 19.13 shows invalid syntax
Submitted: 2007-08-15 22:48 UTC Modified: 2007-08-15 23:03 UTC
From: phpbugs at colin dot guthr dot ie Assigned: colder (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2007-08-15 22:48 UTC] phpbugs at colin dot guthr dot ie
Description:
------------
On the following manual page:
http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php

Example 19.13 gives the code listed below. This causes a parse error.

Reproduce code:
---------------
<?php
class OtherClass extends MyClass
{
    public static $my_static = 'static var';

    public static function doubleColon() {
        echo parent::CONST_VALUE . "\n";
        echo self::$my_static . "\n";
    }
}

$classname = 'OtherClass';
echo $classname::doubleColon();

OtherClass::doubleColon();
?> 

Expected result:
----------------
I would expect $classname::doubleColon() call to succeed according to the docs.

The alternative [call_user_func(array($classname, 'doubleColon'))] is not quite as neat in code.

Judging by comments on the above linked page this has not worked since 2005!

Actual result:
--------------
PHP Parse error:  syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting ',' or ';' in file.php on line 13


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-15 22:57 UTC] bjori@php.net
This syntax was added in PHP5.2.4RC1 but reverted in PHP5.2.4RC2 and won't be available until PHP5.3.0 (not 5.2.4 as the comment there says).

This was fixed in CVS earlier today
 [2007-08-15 23:03 UTC] phpbugs at colin dot guthr dot ie
Haha! Spooky timing :)

Thanks for the very fast response.

FWIW, I now see the reference to 5.2.4 but I didn't see it first time round. It may be worth pointing this out clearly next to the example also.

Thanks again.

(PS I don't expect any further response - just adding my comments for clarity)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Nov 20 04:00:01 2025 UTC