Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Object-Oriented PHP Basics Building the Recipe Cleaning Up the Class

ERRO WORK WITH RECIPES.PHP

I ĐONT KNOW WHAT WRONG

<?PHP
$recipe1 = new Recipe();//LINE ERRO
$recipe1->source ="Minh Phuc 1";
$recipe1->setTitle("my frist title");
$recipe1->addIngredient("egg", "one", "doz");
?>

ERRO

 php classes/recipes.php            
PHP Parse error:  syntax error, unexpected '$recipe1' (T_V
.php on line 56   

Hey This usually means that you did not close tag before this line. As error says this is line 56. Go up and check previous tags. You might be missing semi-colon or coma.

3 Answers

We need to see your recipes.php file, as the error is on line 56 in that file. Please follow up with the new code, and I'd be happy to help.

You also need to include/require said class. --Just for people seeing this question.

Is your comment that the error is in the 2nd line of code you posted? Could it be that you need to change the "php" tag to lowercase? Case shouldn't matter for the php tag, but this site says if you're using XHTML it must be lowercase.

https://www.sitepoint.com/community/t/capital-tags-or-lowercase-tags/4754/2