SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    (double) question

    Hi

    I have often seen the use of the word 'double' between paranthesis used to seed the random number generator. I tried to find if it was part of a function or something.

    could anyone tell me more about it?

  2. #2
    SitePoint Wizard Dangermouse's Avatar
    Join Date
    Oct 2003
    Posts
    1,024
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That casts something to type 'double'. Google type casting

    Basically it converts one type to another, eg

    PHP Code:
    $float 5.6;
    echo (int) 
    $float
    Will output 5 because it is now an integer

  3. #3
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dangermouse
    That casts something to type 'double'. Google type casting
    thanks a lot for your reply.

    Unfortunately I am not sure I understand what you mean

  4. #4
    SitePoint Wizard Dangermouse's Avatar
    Join Date
    Oct 2003
    Posts
    1,024
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    It's a data type. Check the link Danger posted. Basically while PHP is dynamically-typed (ie. the parser can pick a variables data type), you can be more specific if you want or the situation calls for it, say if you were accepting external data and wanted to validate it. Example:
    PHP Code:
     // $_GET['id'] is set to ''--; drop table users;'
     
    $id = (int)$_GET['id']; // $_GET['id'] = 0; 

  6. #6
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok now it does make sense

    thank to your explanations I could find the relevant manual page. In case someone had the same question:

    http://www.php.net/manual/en/language.types.float.php

    thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •