PHP4 and PHP5

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
theBond
Forum Newbie
Posts: 19
Joined: Thu Jul 17, 2008 7:46 pm

PHP4 and PHP5

Post by theBond »

Can I use the below code for portability?

Code: Select all

 
function cleanData( $value )
{
    $trim_value = trim($value); 
    
    if( get_magic_quotes_gpc() )
    {
          $trim_value = stripslashes( $trim_value );
    }
    
    if( function_exists( "mysql_real_escape_string" ) )
    {
          $trim_value = mysql_real_escape_string( $trim_value );
    }
    
    else
    { 
          $trim_value = addslashes( $trim_value );
    }
    
    return $trim_value;
} 
 
//usage
 
$name = cleanData($_POST['name']);
$id = cleanData($_POST['id']);
 
 
Post Reply