SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: ( void )

  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    ( void )

    int rand ( void )
    The quote above is from the manual.

    What does void mean?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    In this case I guess it means empty, non existing. In other words, rand(), without giving it the two parameters.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    http://us2.php.net/manual/en/language.pseudo-types.php
    void

    void as a return type means that the return value is useless. void in a parameter list means that the function doesn't accept any parameters.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    A void in English is an empty space, so it means the function doesn't accept any arguments. If you pass it any arguments, it will produce an error.

    You will also see things like this:

    PHP Code:
    void echo ( string $arg1 [, string $...] ) 
    That means the function doesn't return anything.

    Edit:

    I guess we pretty much fully covered it.

  5. #5
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dotJoon View Post
    The quote above is from the manual.

    What does void mean?
    in the context of the manual

    If called without the optional min, max arguments rand() returns a pseudo-random integer between 0 and getrandmax(). If you want a random number between 5 and 15 (inclusive), for example, use rand(5, 15).
    it means that passing input parameters to the function is optional

    example:

    if in your code you have

    Code:
     
    $randNum = rand();
    $randNum will have a value between 0 and getrandmax


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
  •