Re: Re: [PHP4BETA] array_walk: calling functions taking only ONE paramet && calling methods = not possible?

From: Date: Mon, 29 May 2000 16:02:59 +0000
Subject: Re: Re: [PHP4BETA] array_walk: calling functions taking only ONE paramet && calling methods = not possible?
References: 1 2 3 4 5  Groups: php.dev 
Request: Send a blank email to php-dev+get-19696@lists.php.net to get a copy of this message
On Mon, May 29, 2000 at 05:56:04PM +0200, waldschrott wrote: > so we can stay at the point that using array_walk() within classes is > not possible if one wants to call a function which only accepts one > parameter, so I´m not able to manipulate some arrays inside a class you cannot pass a the name of a object's-method where PHP expects a name to a user-land callback function. that is the current design. we are aware of this limitation. using references you should be able to write a "normal" function and keep &$this in some global variable. though i do agree that this is not a nice way of doing things. > > catching (2) in the future would eliminate the need for (1), one can > then create wrapper methods > > should I create a bug report for this? a feature-request would be more appropiate;-) tc > > regards > > > > On Mon, May 29, 2000 at 05:29:27PM +0200, waldschrott wrote: > > > sorry, did not think about posting to both lists... > > > > > > here is the 10 line (comments not counted) simplified example, it does > > > not do what it has done before, but it demonstrates the both cases 1) and 2) > > > $this->array should consist of an array with printable examples to the > > > selected type, because this did not work i had to work around it, but I > > > think calling methods and accessing functions needing one parameter are > > > important things > > > > > > regards > > > > > > --- snip --- > > > <?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'); > > > > sorry only user-functions can be called by array_walk (and > > all other functions that accept a callback like this) > > > > so you need to create a functions in your script that then > > calles htmlspecialchars() and you should be fine. > > > > > > > // 2 does not work, as said > > > array_walk($this->array,'this->wrapper'); } > > > > this is not supported right now - might get added somewhen in > > the future! > > > > > > tc > > > > > > > > function wrapper(&$param1,$param2='') { > > > return htmlspecialchars($param1); }} > > > ?> > > > --- snip --- > > > > > > > On Mon, May 29, 2000 at 04:41:10PM +0200, waldschrott wrote: > > > > > Hi, > > > > > I tried to things with array_walk. > > > > > 1) Calling a function like htmlspecialchars() with array_walk(), but it > > > > > does not work: results in a wrong parameter count in array_walk(), I > > > > > think array_walk() tries to use the numeric key as a second parameter > > > > > for htmlspecialchars(), how do I avoid this. > > > > > 2) After that I tried to avoid that calling a wrapper method in > > > > > array_walk, I then had to notice that it´s not possible to call methods > > > > > with array_walk(); > > > > > > > > calling methods is currently not implemented for most > > > > functions that have php-callbacks. > > > > > > > > > > > > > > Either array_walk is missing some functionality or I am missing > > > > > something.... > > > > > > > > any chance to send a short (10 lines) script that shows the > > > > behaviour? > > > > > > > > > > > > > > regards > > > > > > > > > -- > > > > Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" > > Digital Collections Phone +49 40 235350 Fax +49 40 23535180 > > Hammerbrookstr. 93 20097 Hamburg / Germany > > > > -- > > PHP Development Mailing List <http://www.php.net/> > > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > > For additional commands, e-mail: php-dev-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > > -- > o----------0-¬---------O-·---¬----o---®-----o o O ° . > | http://www.kiffen.de | pRoteçt y0ur bRaín |0 O ° ¤ > ° · > > 0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ ° > o © ° . · > | psychedelic experience | gott@kiffen.de | O ° o ° > o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ · -- Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany

« previous php.dev (#19696) next »