A: 
$slcustom48 = (int)$slcustom48;
if ($slcustom48) { // will be better and don't allow $slcustom48 be == 0.

Your test will be passed by "123'; DROP TABLE myTable--" :)

$slcustom48 = (int)$slcustom48;
if ($slcustom48 > 0) { // even better
valya
+1  A: 
>>> $foo = NULL
>>> $foo != 0
false
>>> $foo == 0
true

PHP treats variables with a NULL value as the integer 0 with the == operator so the NULL check is indeed redundant.

yjerem
But the question is: "...when checking for a value greater than zero?" You make a good point, but it's still not redundant.
marcc
+2  A: 

Your code doesn't even check if a value is greater than 0, which is your question, so no. My answer is no. It's not redundant. It's not correct.

marcc
+1  A: 
$slcustom48=(bool)$slcustom48;

if($slcustom48) 
{

// do something

} 
else 
{

// do something else

}

pradeepa
You're first line is redundant. Conditions in if statements are automatically interpreted as boolean. Also, your code doesn't guarantee the variable holds an integer. It simply casts whatever is in there (which could be a string or even an object) to a boolean.
fireeyedboy
+2  A: 

First of all, marcc is right: You're code doesn't check whether the variable holds a value greater than zero. It simply tests whether the variable is NOT zero (could be a negative number, but also a string or an object, etc.)

So expanding on that thought: you're not checking whether the variable holds an integer. What you DO check is whether the variable holds a value at all, with != NULL. But the order in which you have this in your if condition is the wrong way around. Here's why:

To prevent a notice in your error log (or appearing on screen on a test server) you need to check whether the variable holds anything at all BEFORE you check anything else. PHP will stop interpreting the conditional as soon as it returns false. This can be done also with PHP's isset() or indeed with != NULL.

Next, you need to make sure that the variable holds an integer (if that's important to you, which I think should be important to you IMHO).

Lastly, you want to check whether the value of the variable is larger than zero. So, to sum it up, this is what you need:

if( isset( $slcustom48 ) && is_int( $slcustom48 ) && $slcustom48 > 0 )
{
    // the variable indeed holds an integer larger than zero
}
fireeyedboy
fireeyedboy, thank you for taking the time to explain the logic.
digidave0205