SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parameter defaults and references

    Hey all

    I'm a tad confused how to do this. I want to pass an array to a function - but only pass a reference. I also want a default value, as a reference.

    For the first, I assume it's this

    function blah( &$param )
    {
    // code
    }

    blah( $_GET );

    but I really have no idea how to capture a param as a reference, but also make it optional by setting a default - also as a reference. Am I making any sense?
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  2. #2
    SitePoint Guru
    Join Date
    Oct 2001
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not possible in PHP 4. Parameters passed by reference can not have default values. PHP 5 will support this though, so if you have a few months time

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh - no wonder I can't get it working [img]images/smilies/tongue.gif[/img]

    Thanks
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





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
  •