What is the difference between following functions?
Does these both functions perform same task?

$wh_ope=clean($_POST['whop'])?(int)$_POST['whop'] : 0;
$wh_ope=(int)clean($_POST['whop']); 


function clean($str)
    {
    $cstr=trim($str);
    $cstr=addslashes($str);
    $cstr=strip_tags($str);
    $cstr=htmlspecialchars($str);
    return $cstr;
    }

Recommended Answers

Neither are good code. A string is not an integer. The length may be. Any character of the string can be considered an integer, but the string itself is not. What are you trying to accomplish here?

Jump to Post

All 3 Replies

Neither are good code. A string is not an integer. The length may be. Any character of the string can be considered an integer, but the string itself is not. What are you trying to accomplish here?

Trying to get zero (0) if there is NULL or empty string.
Want to save 0 instead of NULL.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.