PHP 5.4 WARNING



Wait, this has been deprecated?

Edit: This hasn't been deprecated. What has been deprecated is something like this:

Code:
$x=5;
$y=2;

play_game($x, &$y);

function play_game($x, $y) { 
   $x = 9;
   $y = 4;
}

Balance has been restored to the universe now that I don't have 40 hours rewriting all my code.

Deprecated in 5.3 REMOVED in 5.4.
 
The fuck? Don't scare me like that. References haven't been depricated, they just got rid of the retard way of using them. I use references all the time to save memory.

You almost had me switching to C.
 
There's no real global variables in PHP (other than $GLOBALS array). For example, if I put "$z = 6" at the top of that code snippet, the play_game() function wouldn't be able to see to $z.

You can do this

PHP:
$z = 6;

function play_game()
{
global $z;

echo $z;

}

and it will work. Not something I like to do but it works.

I prefer constants myself:

PHP:
define("NUMBER",     1);
echo NUMBER;


The fuck... I've been coding a long time, circa 1995, thank god not in php, cause I don't see that shit working right here. Maybe you left some code out, or this is a troll - I don't know anymore.

It was called "passing by reference". I remember coming across it deep in osCommerce code from around '03 and spending a few hours puzzling it out. In case anyone wants the docs + where it was deprecated / removed:

PHP: Passing by Reference - Manual
 
Wait, this has been deprecated?

Edit: This hasn't been deprecated. What has been deprecated is something like this:

Code:
$x=5;
$y=2;

play_game($x, &$y);

function play_game($x, $y) { 
   $x = 9;
   $y = 4;
}
Balance has been restored to the universe now that I don't have 40 hours rewriting all my code.

Phew, you're right. Just upgraded a server I don't really use to PHP v5.4, and that code snippet I posted above works fine.

That's a relief.
 
That code I posted? It works fine. I just tested it myself:

Code:
$x=5;
$y=2;

echo "X = $x, Y = $y\n";
play_game($x, $y);
echo "X = $x, Y = $y\n";

function play_game($x, &$y) {
   $x = 9;
   $y = 4;
}

Run that, and the output will be:

Code:
X = 5, Y = 2
X = 5, Y = 4

Or what PHP version are you using? Apparently, if it's v5.4+, it's not going to work. My devel server is v5.3.9.

Works on php 5.4.6