PHP Newsletter

Join now and receive weekly updates pertianing to the world of PHP.

Polls

What do you think about the new PHPMine Design?
Awesome
Not Bad
Sucks

PHP Gigs By City

PHP Jobs By Topic

Advertisements

in how many cases can i use (int) ¨php¨?

Asked 2010-03-16 15:20:59 by jc_yurcastle


Anwered 2010-03-16 17:52:35 by Robin T

One. In this question that you asked :)

If you try to parse a string to an int this is what you get:
1. (int) "1234" => 1234
2. (int) "1234blah5678" => 1234
3. (int) "blah" => 0
4. (int) "blah1234" => 0

Anwered 2010-03-16 23:00:27 by CJ

Well it will depend how you look at it.. and depending if you consider different syntax as a different case.
eg:


$x = 123;

$number = (int) $x;

$number = ((is_numeric($x)? (int) $x:0);

Questions and answers provided by the Yahoo Answers Community.