You are here: Re: [PHP] array_map() problems « PHP « IT news, forums, messages
Re: [PHP] array_map() problems

Posted by Guillermo Rauch on 02/08/05 01:33

Hi Jeffery,

To use a class method as a valid callback, you should pass an array like

$_POST = array_map(array($this, 'StripSlashesDeep'), $_POST);

Hope this helps,
-Guillermo

On Mon, 7 Feb 2005 17:10:32 -0600, Greg Donald <destiney@gmail.com> wrote:
> On Tue, 08 Feb 2005 09:37:11 +1100, Jeffery Fernandez
> <forums@jefferyfernandez.id.au> wrote:
> > I have the following 2 functions which I intend to clean GPC off slashes
> > if magic_quotes_gpc is turned on.
> >
> > function StripGpcSlashes()
> > {
> > if (get_magic_quotes_gpc())
> > {
> > $_POST = array_map('StripSlashesDeep', $_POST);
> > $_GET = array_map('StripSlashesDeep', $_GET);
> > $_COOKIE = array_map('StripSlashesDeep', $_COOKIE);
> > }
> > }
> >
> > function StripSlashesDeep($value)
> > {
> > $value = is_array($value)
> > ? array_map('StripSlashesDeep', $value)
> > : stripslashes($value);
> >
> > return $value;
> > }
> >
> > However when I call $this->StripGpcSlashes(); from within a class, I get
> > the following error:
> > */ array_map(): The first argument, 'StripSlashesDeep', should be either
> > NULL or a valid callback /*
> >
> > Anyone have suggestions as to what I am doing wrong ?
>
> Mine works fine, but I don't use it in any classes:
>
> set_magic_quotes_runtime(0);
> if(get_magic_quotes_gpc() == 0){
> $_GET = isset($_GET) ? array_map("slashes", $_GET) : array();
> $_POST = isset($_POST) ? array_map("slashes", $_POST) : array();
> $_COOKIE = isset($_COOKIE) ? array_map("slashes", $_COOKIE) : array();
> }
>
> function slashes($var){
> if(is_array($var))
> return array_map("slashes", $var);
> else
> return addslashes($var);
> }
>
> --
> Greg Donald
> Zend Certified Engineer
> http://destiney.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация