function parameter question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • petermichaux@yahoo.com

    function parameter question

    Hi,

    What does the "=array()" mean? It works with or without it in PHP5. The
    code was written for pre-PHP5.

    public function getPhrase($a_st Name, $a_astValues = array())

    Thanks,
    Peter

  • Don Freeman

    #2
    Re: function parameter question


    <petermichaux@y ahoo.com> wrote in message
    news:1121801366 .629527.288570@ g49g2000cwa.goo glegroups.com.. .[color=blue]
    > Hi,
    >
    > What does the "=array()" mean? It works with or without it in PHP5. The
    > code was written for pre-PHP5.
    >
    > public function getPhrase($a_st Name, $a_astValues = array())
    >[/color]
    A question: what is the "public" qualifier for? I know what it means in
    Java but I haven't seem it used in PHP before.


    Comment

    • petermichaux@yahoo.com

      #3
      Re: function parameter question

      public is for php5 class methods. They can also be private or
      protected.

      Maybe I figured out my question. Does "= array()" simply create an
      default empty array if a second parameter is not supplied in the call
      to the method?

      Comment

      • Good Man

        #4
        Re: function parameter question

        petermichaux@ya hoo.com wrote in news:1121802375 .034979.24930
        @o13g2000cwo.go oglegroups.com:

        [color=blue]
        > Maybe I figured out my question. Does "= array()" simply create an
        > default empty array if a second parameter is not supplied in the call
        > to the method?[/color]

        bingo.

        same as

        function doit ($x=11) {
        //do stuff with $x
        }

        will give $x a default of 11 if the parameter is not supplied in the call
        to the function....



        Comment

        • petermichaux@yahoo.com

          #5
          Re: function parameter question

          Thanks!

          Comment

          Working...