PHP递归调用

By Symphony - Last updated: Sunday, June 8, 2008 - Save & Share - Leave a Comment

function daddslashes($string, $force = 0)
{
!defined( ‘MAGIC_QUOTES_GPC’ ) && define( ‘MAGIC_QUOTES_GPC’ , get_magic_quotes_gpc() );

if(!MAGIC_QUOTES_GPC || $force)
{
if(is_array($string))
{
foreach($string as $key => $val)
{
$string[$key] = daddslashes($val, $force);
}
}
else
{
$string = addslashes($string);
}

}

return $string;
}

红色部分写得很帅,绿色的部分我不赞同

改为

defined( ‘MAGIC_QUOTES_GPC’ ) or define( ‘MAGIC_QUOTES_GPC’ , get_magic_quotes_gpc() );

( 0 == MAGIC_QUOTES_GPC ) or $force

更直观

Posted in Uncategorized • Tags: Top Of Page

Write a comment