#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Nobbies beach, Gold Coast. It's beautiful.
    Posts
    2,570
    Rep Power
    171

    Using brackets [] in function arguments


    Is there any situations to have brackets in the arguments sent to a function?For example:
    PHP Code:
    show($argument_1$argument[], $argumnet['something']); 
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,911
    Rep Power
    1045
    Hi,

    I guess you have PHP installed somewhere, so copy the line into a script (with a dummy definition for show), turn the error messages all up and run it.
  4. #3
  5. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,746
    Rep Power
    9397
    The first one is probably (hopefully) passing by-reference, the second is just passing a regular value.
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,911
    Rep Power
    1045
    It doesn't pass anything, it just crashes with a fatal error.
  8. #5
  9. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,746
    Rep Power
    9397
    It does?
    PHP Code:
    function example($first$second, &$third) {
        
    print_r(func_get_args());
        
    $third 3;
    }

    $array = array(12);
    example($array[0], $array[1], $array[]);
    print_r($array); 
    Code:
    Array
    (
        [0] => 1
        [1] => 2
        [2] =>
    )
    Array
    (
        [0] => 1
        [1] => 2
        [2] => 3
    )

    Comments on this post

    • Jacques1 agrees : I stand corrected.
    • E-Oreo agrees : Didn't realize this was possible

IMN logo majestic logo threadwatch logo seochat tools logo