passing references

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

    passing references

    hi all,
    i have some doubts in passing variables by references in php.
    i usually use
    class blah
    {
    function Params( &$params)
    {
    $this->params =& $params;
    }
    }
    where $params is an array.
    is the second & unnecessary?
    is there any difference if $params is object instead of array?

    thnx

    tole


  • point

    #2
    Re: passing references

    Actually it is not a bad idea to do it so...

    A few months ago I asked the same question and it was:

    Is this good coding practice:

    $var = & nl2br($var);

    The conclusion of the debate was:

    the worst thing it can happen is nothing...

    the best thing it can happen is a bit of time & memory saving.....

    hope this helps....

    point


    "Tole" <tole_carOBRISI OVAJDIO@yahoo.c om> wrote in message
    news:bj49kr$f95 fr$1@ID-132821.news.uni-berlin.de...[color=blue]
    > hi all,
    > i have some doubts in passing variables by references in php.
    > i usually use
    > class blah
    > {
    > function Params( &$params)
    > {
    > $this->params =& $params;
    > }
    > }
    > where $params is an array.
    > is the second & unnecessary?
    > is there any difference if $params is object instead of array?
    >
    > thnx
    >
    > tole
    >
    >[/color]


    Comment

    • Why?

      #3
      Re: passing references

      I thought support for references was being depreciated.

      Why.

      point wrote:[color=blue]
      > Actually it is not a bad idea to do it so...
      >
      > A few months ago I asked the same question and it was:
      >
      > Is this good coding practice:
      >
      > $var = & nl2br($var);
      >
      > The conclusion of the debate was:
      >
      > the worst thing it can happen is nothing...
      >
      > the best thing it can happen is a bit of time & memory saving.....
      >
      > hope this helps....
      >
      > point
      >
      >
      > "Tole" <tole_carOBRISI OVAJDIO@yahoo.c om> wrote in message
      > news:bj49kr$f95 fr$1@ID-132821.news.uni-berlin.de...
      >[color=green]
      >>hi all,
      >>i have some doubts in passing variables by references in php.
      >>i usually use
      >>class blah
      >>{
      >> function Params( &$params)
      >> {
      >> $this->params =& $params;
      >> }
      >>}
      >>where $params is an array.
      >>is the second & unnecessary?
      >>is there any difference if $params is object instead of array?
      >>
      >>thnx
      >>
      >>tole
      >>
      >>[/color]
      >
      >
      >[/color]

      Comment

      Working...