Page 1 of 1

Parse Error - PHP - Simple .. I hope - unexpected '$'

Posted: Thu Sep 21, 2006 9:54 pm
by drewrockshard
I am messing around with PHP, and I seem to be getting the error of:
parse error, unexpected '$', expecting '&' or T_VARIABLE
There error is actually on "line 5", which in the case of the extra code and such, "line 5" seems to be:
function addIt($1) {
Here is the whole script:

Code: Select all

function addIt($1) {
	$1 = 0;
	if ($1 == 1) {
		echo "This would be true";
	}
	elseif ($1 == 0) {
		echo "This would be false";
	}
	else { 
		echo "I encountered an error"; 	
	}
	return $1;
}
Also in the body of the PHP file (let's call it index.php - what the user will see), I have called the function using:

Code: Select all

<?php addIt(0); ?>
Let me know if you can see the error .. I can't .. And I am running off of 4 hours of sleep .. so it could just be minor .. someone ... please .. thanks :)

Posted: Thu Sep 21, 2006 10:00 pm
by ambivalent

Posted: Thu Sep 21, 2006 10:04 pm
by drewrockshard
Duh .. thanks for your help. It worked .. of course ... As always .. simple freakin error .. on my part ..