Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,403 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.