Epic Voyage logo

Epic Voyage

The Wanderer's Journal

Main menu

  • Home

Geek Stuff: Bizarre PHP Code

I won’t incriminate this project’s coders, but they do sell their work that is based on vBulletin. One of their free projects contains a function that has three arguments passed to it. The first argument is immediately overwritten by a global. Here is a stripped down example:

<?php
$hello = 'hello';
$world = 'world';

function test(&$hello) {
    global $hello;
    echo "$hello\n";
}

test($world);
echo "$hello $world\n";

?>

And the output of my function:

$ php test.php
hello
hello world

$world is passed by reference as $hello. It is promptly ignored in favor of the global $hello variable, without even overwriting $world. They should remove the required parameter $hello.

Overheard at the Tavern

To pass lightly from old laws to new ones is a certain means to weakening the inmost essence of all law whatever. — Aristotle
Another »

Since This Page Loaded...

0 million dollars have been spent by Washington.
0.00 dollars per person in the US.

And that is only Federal spending...

0 babies have died worldwide in an abortion.
0 babies were in the United States.

0 Americans have contracted an STD.

About Me

{author}
Chris is probably out getting lost somewhere. He has a tendency to do that. Please don't worry unless he fails to show up again sometime in the next week.

Copyright 2024. All rights reserved.