functions, which returns changes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sonnich

    #1

    functions, which returns changes

    Geee cannot remomber

    I'd like to do this:

    function blabla(var $something_to_b e_updated)
    {
    $something_to_b e_updated++;
    }

    but it is not var. How do I do this?

    Is there a better way than a function for this?

    s

  • Jay

    #2
    Re: functions, which returns changes

    I'm not sure what you mean

    $something_to_b e_updated;

    function update() {
    global $something_to_b e_updated;
    $something_to_b e_updated++;
    }

    or

    function update($somethi ng_to_be_update d) {
    return $something_to_b e_updated++;
    }


    Sonnich wrote:
    Geee cannot remomber
    >
    I'd like to do this:
    >
    function blabla(var $something_to_b e_updated)
    {
    $something_to_b e_updated++;
    }
    >
    but it is not var. How do I do this?
    >
    Is there a better way than a function for this?
    >
    s

    Comment

    • Sonnich

      #3
      Re: functions, which returns changes

      Note the var.
      I want to pass on a variable, which is changed in the subroutine.

      so::

      $i = 54;
      blabla($i);
      $i is is now 55

      S


      Jay wrote:
      I'm not sure what you mean
      >
      $something_to_b e_updated;
      >
      function update() {
      global $something_to_b e_updated;
      $something_to_b e_updated++;
      }
      >
      or
      >
      function update($somethi ng_to_be_update d) {
      return $something_to_b e_updated++;
      }
      >
      >
      Sonnich wrote:
      Geee cannot remomber

      I'd like to do this:

      function blabla(var $something_to_b e_updated)
      {
      $something_to_b e_updated++;
      }

      but it is not var. How do I do this?

      Is there a better way than a function for this?

      s

      Comment

      • ZeldorBlat

        #4
        Re: functions, which returns changes


        Sonnich wrote:
        Note the var.
        I want to pass on a variable, which is changed in the subroutine.
        >
        so::
        >
        $i = 54;
        blabla($i);
        $i is is now 55
        >
        S
        >
        >
        Jay wrote:
        I'm not sure what you mean

        $something_to_b e_updated;

        function update() {
        global $something_to_b e_updated;
        $something_to_b e_updated++;
        }

        or

        function update($somethi ng_to_be_update d) {
        return $something_to_b e_updated++;
        }


        Sonnich wrote:
        Geee cannot remomber
        >
        I'd like to do this:
        >
        function blabla(var $something_to_b e_updated)
        {
        $something_to_b e_updated++;
        }
        >
        but it is not var. How do I do this?
        >
        Is there a better way than a function for this?
        >
        s
        You want this:

        function blabla(&$someth ing_to_be_updat ed) {
        $something_to_b e_updated++;
        }

        Read this:
        <http://www.php.net/manual/en/language.refere nces.pass.php>

        Comment

        Working...