PHP warning. What does it mean?

Discussion in 'HTML / PHP / JavaScript / CSS' started by _EarnIt_, Nov 22, 2003.

  1. Bruce,

    Thanks for the tip. I searched a little bit more and found the offending part of the code. Here was my change:

    Original code:
    $parsed_data[$i] = parse_profile(&ret_data[$i]);

    New Code:
    $parsed_data[$i] = parse_profile($ret_data[$i]);

    for some reason that I don't understand, dropping the "&" symbol fromt the code line made all the difference.

    Thanks for the help.


    quote:Originally posted by bruce

    Did this use to work before?

    We upgraded to the latest stable version of PHP 4.3.1 couple nights ago.

    I did a search on google and found that many people have experienced this problem. See one of the thread

    http://groups.google.com/groups?hl=...34%24tfk%241%40news-reader1.wanadoo.fr&rnum=3

    quote:Originally posted by _EarnIt_

    http://www.warwrights.org/Zone_Ratings/AoCLiveRatings/index.php

    On the above page, I get the following error,

    PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in E:\web\warwrightso\htdocs\Zone_Ratings\AoCLiveRatings\index.php on line 67

    Does anyone have any idea why or how to fix it?

    Thanks

    _EarnIt_
    (How else can you get any where in life)
    </blockquote id="quote"></font id="quote">
    </blockquote id="quote"></font id="quote">

    _EarnIt_
    (How else can you get any where in life)
     
  2. http://www.warwrights.org/Zone_Ratings/AoCLiveRatings/index.php

    On the above page, I get the following error,

    PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in E:\web\warwrightso\htdocs\Zone_Ratings\AoCLiveRatings\index.php on line 67

    Does anyone have any idea why or how to fix it?

    Thanks

    _EarnIt_
    (How else can you get any where in life)
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    Did this use to work before?

    We upgraded to the latest stable version of PHP 4.3.1 couple nights ago.

    I did a search on google and found that many people have experienced this problem. See one of the thread

    http://groups.google.com/groups?hl=...34%24tfk%241%40news-reader1.wanadoo.fr&rnum=3

    quote:Originally posted by _EarnIt_

    http://www.warwrights.org/Zone_Ratings/AoCLiveRatings/index.php

    On the above page, I get the following error,

    PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in E:\web\warwrightso\htdocs\Zone_Ratings\AoCLiveRatings\index.php on line 67

    Does anyone have any idea why or how to fix it?

    Thanks

    _EarnIt_
    (How else can you get any where in life)
    </blockquote id="quote"></font id="quote">
     
  4. I had this problem quite a while back. Just in case you're curious, heres an explanation of the error.

    Passing a variable 'by reference' means that the variable will change if the function modifies the value. The reason it says 'call-time pass-by-reference' is deprecated is because the variable should be defined as by reference in the function rather than in the call. Heres an example:

    function blah($myVar)
    {
    $myVar = $myVar + 1;
    return $myVar;
    }
    $test = 5;
    blah(&$test);

    This is not a good way to handle this situation because if the function is modified later, it may not give the expected result. Instead, you should use this (note the placement of the & in the function declaration rather than the call):

    function blah(&$myVar)
    {
    $myVar = $myVar + 1;
    }
    $test = 5;
    blah($test);

    Now, even without the & in the call, the variable passed will automatically be passed by reference. This kind of implies that there will be modifications to the variable and they are most likely expected. As a note, another reason for passing by reference is, for example, if you are using an array or class and you do not want to create a new copy in the function. In C/C++, this makes it work quicker (so it may be the same in PHP) and also lets the function modify the values.

    One last note, when you see a warning that something is deprecated, that does mean that it worked previously and still works. PHP gives deprecated warnings to let you know that you need to update your source to follow new guidelines [:)]

    Lots of tech articles and other stuff (soon, I hope!) at http://www.emptycauses.com
     

Share This Page