php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9552 array_walk and classes
Submitted: 2001-03-04 19:18 UTC Modified: 2001-03-04 19:28 UTC
From: bbak at wob dot ag Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.0.4pl1 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: bbak at wob dot ag
New email:
PHP Version: OS:

 

 [2001-03-04 19:18 UTC] bbak at wob dot ag
Well maybe noone will ever use array_walk in Classes, but this should at least be documented:
_________SCRIPT_____________
class foo {
	var $files = array();
	
	// CONSTRUCTOR
	function foo() {
                // fill up the files array
		$this->files = $this->memberfunc_1();
		// do something with the array
                array_walk($this->files, "$this->memberfunc_2");
		// or "memberfunc_2" or "this->memberfunc_2"
	}
		
	// create a unique filename and clean up the real filename
	function memberfunc_2(&$c_arr) {
		// do some stuff ....
	}
} // end class

$bar = new foo();
____________END SCRIPT______________

This code leads to an Error Like :
Warning: Unable to call this->memberfunc_2() - function does not exist in .....



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-04 19:28 UTC] andrei@php.net
It is possible to call object methods with array_walk().
Try the following:

array_walk($this->files, array($this, "memberfunc_2"));
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC