Skip to main content
ErrorsMagento

Magento – Use of undefined constant php – assumed ‘php’

By March 2, 2015April 28th, 2015One Comment

A few weeks back I was tasked with developing a Magento website, that had been started by another developer. After moving the site to new hosting I noticed lots of ‘undefined constant’ errors, when looking through the system.log error logs.

2015-02-20T07:27:27+00:00 ERR (3): Notice: Use of undefined constant php - assumed 'php'  in
/../../../catalog/product/list.phtml on line 150

Unfortunately the line numbers didn’t originally match up and were often longer than the file itself. Googling the error also wasn’t much help for once, instead vaguely pointing to a malformed tag or the wrong quotes. This wasn’t much help for a large Magento site, with lots of custom code.

Let the Needle in a Haystack Search Begin

With the error firing constantly, I thought it must be in a global include such as the header or footer, but after digging around in various theme files I still couldn’t find the issue.

After adding a few traces and visiting only specific areas of the test site, I noticed the error was in the product listing code on landing pages.

The culprit was a badly commented block of code that had comment tags within comment tags, without a space. The offending code was in various templates, so may have been the result of some trigger happy find and replacing.

Notice: Use of undefined constant php – assumed ‘php’

So if you find the error “Use of undefined constant php – assumed ‘php'” in your Magento build, do a quick search for;

<php/*

<php//

I hope that helps someone else out there!

Andrew Taylor

A senior UI designer with over 25 years of web design and web development experience working for some of the largest companies in the UK. An expert in all things Magento and WordPress.

One Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.