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 Understanding Classes Accessing Properties

Unable to run PHP in Chromium console under Ubuntu. Produces "Uncaught SyntaxError: Unexpected identifier(...)"

Hi,

When I try to replicate what the instructor is doing in my console in Chromium I receive the above error. The code in my php script is an exact replica of the instructors. I suspect more to do with trying to run a php script in my console (something I've never attempted before). Googling a solution did not bear useful fruit. I know my localhost setup has PHP installed and running. It has been some years since I mucked about in php though so may just be simple newbie problem. Any help much appreciated.

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

A web browser's console runs a completely different language: JavaScript. PHP has to be run through a web server or you can run a script through the terminal with the php command. This usually involves installing PHP, webserver and database through your system's software manager.

http://howtoubuntu.org/how-to-install-lamp-on-ubuntu

Thanks Seth. Have been trying to do something in console that I should have been doing in terminal. Been a long time since I messed with PHP and then was always via web page. Checked code ran OK in terminal (did have syntax errors after all) - all checked out after coupla tweaks. Thanks for your prompt reply.