NYCPHP Meetup

NYPHP.org

[nycphp-talk] global variables

Malcolm, Gary gmalcolm at professionalcredit.com
Thu May 22 13:47:02 EDT 2003


I've been told best practice is to NOT use globals in functions, if simply
for readability but I bet we all do :) . Also, I wonder if a passed
reference to a variable is as efficient... does anyone have an opinion on
which of these is better and why (as a general rule)
1)

	$var foo;
	function  bar(&$foo){
		do stuff to change $foo
	}

2)
	var $foo = bar();
	function bar(){
		do stuff
		return a value for $foo
	}

3)
var $foo;
bar();
function bar(){
	global $foo;
	do stuff to change $foo
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20030522/2e8b1cbc/attachment.html>


More information about the talk mailing list