php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #16979 nested function in functions within a class
Submitted: 2002-05-02 18:29 UTC Modified: 2012-09-22 09:13 UTC
From: lazybrain at rcn dot com Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 4.1.2 OS: bsd
Private report: No CVE-ID: None
 [2002-05-02 18:29 UTC] lazybrain at rcn dot com
It would be helpfull to be able to 
use nested functions inside a function thats in a class.

For example...

clase something {

 function test1() {
  do something here

  // quick function to make code smaller
  function test2() {
   do more here
  }
 }

 
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-12 13:57 UTC] ahristov at icygen dot com
AFAIK this code could work. I've written some code this way but the user has to guard the definition of the function somehow or on the second call os test1 there will be fatal error.
 [2012-09-22 09:13 UTC] nikic@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: nikic
 [2012-09-22 09:13 UTC] nikic@php.net
Closing as this already works.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 07:01:33 2025 UTC