Jump to content


Photo

what is this (int) do inside ternary operator?


  • Please log in to reply
1 reply to this topic

#1 bilis_money

bilis_money
  • Members
  • PipPipPip
  • Advanced Member
  • 621 posts

Posted 18 June 2006 - 11:37 AM

ok, i have had visited sitepoint.com

and along the way i got this code;
// If we want more fields, then use, preupload.php?number_of_fields=20
 $number_of_fields = (isset($_GET['number_of_fields'])) ? (int)($_GET['number_of_fields']) : 5;

ok, i know that the variable $number_of_fields was assigned by an isset which is from $_GET
which has a ternary condition.

now my basic question is what is an (int) doing inside a ternary condition operator?
what an (int) purpose?

thanks in advance.

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 18 June 2006 - 02:25 PM

Type casting.

[a href=\"http://www.php.net/language.types.type-juggling#language.types.typecasting\" target=\"_blank\"]http://www.php.net/language.types.type-jug...pes.typecasting[/a]
~ D Kuang




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users