php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21849 self::constant doesn't work as method's default parameter
Submitted: 2003-01-23 16:51 UTC Modified: 2003-02-10 03:46 UTC
From: sebastian@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-01-23 (dev) OS: Windows 2000
Private report: No CVE-ID: None
 [2003-01-23 16:51 UTC] sebastian@php.net
  <?php
  class Foo {
    const Bar = 'Foobar';
  
    function foobar($foobar = Foo::Bar) {
      echo $foobar;
    }
  }
  
  $o = new Foo;
  $o->foobar();
  ?>

works, but

  <?php
  class Foo {
    const Bar = 'Foobar';
  
    function foobar($foobar = self::Bar) {
      echo $foobar;
    }
  }
  
  $o = new Foo;
  $o->foobar();
  ?>

does not and prints "Fatal error: Undefined class 'self' in c:\test.php on line 5".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-09 09:57 UTC] moriyoshi@php.net
Related to bug #18926

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC