php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1074 array_walk and register_shutdown_function
Submitted: 1999-01-15 09:49 UTC Modified: 1999-01-15 11:57 UTC
From: roy dot media at vantage dot nl Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: roy dot media at vantage dot nl
New email:
PHP Version: OS:

 

 [1999-01-15 09:49 UTC] roy dot media at vantage dot nl
The following code does not work:
=====
class myClass {

  function myClass() {
  }

  function testMe() {
    array_walk(array(1,2,3,4), 'showMe');
  }

  function showMe($myElement) {
    print $myElement;
  }
}

$myClass= new myClass();
$myClass->testMe();
=====

However if you place the 'showMe' function outside of the class it will work, but then you get problems when you want to use local vars of the class in the 'showMe' function (offcourse you can declare globals and such, but thats ugly). I am wondering if the same thing applies to the 'register_shutdown_function' function (or any other function that has a 'string func' as an argument). Is there maybe a way to let PHP know you want to use a function in the class you are calling 'array_walk' from? If not i hope somebody fixes it, also it would be nice to have both key and element passed as arguments to 'string func', i know it has been said before.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-01-15 11:57 UTC] zeev
No function in PHP 3.x supports indirect calling of member functions,
including (but not limited to) array_walk and register_shutdown_function.

If you think about it, even outside these functions, you always
have to prefix member functions with $this->, even when you call
them from within the object, so you shouldn't have expected that
notation to work at all.  Regardless, no notation would give you
what you want - you would have to use a global function.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 06:01:31 2024 UTC