note 94561 deleted from function.settype by danbrown

From: Date: Thu, 12 Nov 2009 13:33:06 +0000
Subject: note 94561 deleted from function.settype by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162806@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- What michaltrutman is referring to is setting a variable's type implicitly instead of explicitly. Two common one's that were missed on his/her post are: Changing a variable or expression to boolean using a double-not: <?php $a = !!$a; // $a is now boolean. ?> And you can change a float to an integer using shift operators if the fraction does not matter. This is the same as the floor function: <?php $a <<<= 0; // $a is now an integer. // or.. $a >>>= 0; // $a is now an integer. ?>

« previous php.notes (#162806) next »