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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drewrockshard
Forum Commoner
Posts: 37
Joined: Sat May 29, 2004 6:07 pm
Location: Dallas, Texas
Contact:

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

Post 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 :)
User avatar
ambivalent
Forum Contributor
Posts: 173
Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON

Post by ambivalent »

drewrockshard
Forum Commoner
Posts: 37
Joined: Sat May 29, 2004 6:07 pm
Location: Dallas, Texas
Contact:

Post by drewrockshard »

Duh .. thanks for your help. It worked .. of course ... As always .. simple freakin error .. on my part ..
Post Reply