Why doesnt pass-by-value work?

From: Date: Mon, 05 Mar 2001 00:21:10 +0000
Subject: Why doesnt pass-by-value work?
Groups: php.general 
Request: Send a blank email to php-general+get-42541@lists.php.net to get a copy of this message
When I call this function: function getColumnName($col) { if ($col > 0 && $col < pg_numfields($this->lastResultSet)) return pg_fieldname($this->lastResultSet,$col); else return null; } It returns null all the time ! The condition is NOT the problem ... Ive tested that with: function getColumnName($col) { return pg_fieldname($this->lastResultSet,$col); if ($col > 0 && $col < pg_numfields($this->lastResultSet)) return pg_fieldname($this->lastResultSet,$col); else return null; } And it still returns null. If I do this: function getColumnName($col) { echo pg_fieldname($this->lastResultSet,$col); return pg_fieldname($this->lastResultSet,$col); if ($col > 0 && $col < pg_numfields($this->lastResultSet)) return pg_fieldname($this->lastResultSet,$col); else return null; } I do get the correct result printed to the browser ... So what the HELL is going on? Dont tell me that pass by reference doesnt work with pg_* functions? Just to test this, I did this: function getColumnName($col) { $test = pg_fieldname($this->lastResultSet,$col); return $test; if ($col > 0 && $col < pg_numfields($this->lastResultSet)) return pg_fieldname($this->lastResultSet,$col); else return null; } This made no difference ... WHAT AM I DOING WRONG?! AndrewH

« previous php.general (#42541) next »