php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #4674 limitations of array_walk() calling methods or single-parameter functions
Submitted: 2000-05-29 18:12 UTC Modified: 2000-07-12 20:20 UTC
From: waldschrott at kiffen dot de Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.0 Release OS: All
Private report: No CVE-ID: None
 [2000-05-29 18:12 UTC] waldschrott at kiffen dot de
array_walk() is limited in the way
a) it cannot call methods in classes and
b) it?s not possible to call functions which expect one parameter like htmlspecialchars();

the prior fixing of (a) would enable the user to write a wrapper functions in classes to be able to use single-parameter functions though



Test script:
<?php
$obj=new RX_mail(1);

class RX_mail    {
var $examples=array(1=>array('foo@foo.com','"foo"@subfoo.foo.com', '*@foo.com'),
2=>array('"foobiee" <foo@foo.com>','<subfoo@sub.foo.com>'));
function RX_mail($type) {
$this->array=$this->examples[$type];
// Before returning $this->examples[$type] I wanted to array_walk
// all items to be able to display them

// 1) does not work
array_walk($this->array,'htmlspecialchars');
// 2 does not work, as said
array_walk($this->array,'this->wrapper'); }

function wrapper(&$param1,$param2='')    {
return htmlspecialchars($param1); }}
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-12 20:20 UTC] sterling at cvs dot php dot net
This has been addressed in 4.0.1.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Jun 14 22:00:01 2026 UTC