Use of undefined constant ‘Main’

Permalink
I need help here!

We have a new theme that are converting to C5: We have one page defined with a single template. We have done this many times in the past except using php 5.6.3 so we are comfortable with what we are doing. Also, we reviewed Andrews HTML to C5 vids and confirmed all of our steps.

We simply added an area and now get the error a above (more details below).

Here is the area (inside of a simple div). We've tried without a class, same error.
<div class="flex-caption">
<?php
$a = new Area(‘Main’);
$a->display($c);
?>
</div>

ENVIRONMENT
=============

# concrete5 Version
Core Version - 8.5.4
Version Installed - 8.5.4
Database Version - 20200609145307

PHP 7.3.7

Complete Error Thrown (can provide the stack trace if needed):
================================================
Whoops\Exception\ErrorException thrown with message "Use of undefined constant ‘Main’ - assumed '‘Main’'
(this will throw an Error in a future version of PHP)"

If we change to PHP 5.6.3 (which is what we've used for eons), we get no error, but when adding a content block, the progress bar goes all the way to the right and the little spinny wheel just keeps going around and around. We can add an HTML, Feature Block and a few others - haven't really tested everything, but a Content Block is obviously a key item.

I would really appreciate any insight or suggestions.

Thanks all and enjoy the rest of the holiday season.

 
JohntheFish replied on at Permalink Reply
JohntheFish
The most obvious interpretation of the error message is that you have forgotten to quote the 'Main' area in one of your page templates.
barbedwire replied on at Permalink Reply
Thanks for this, however as stated,

We have only one page template, so not the solution but something to keep in mind going forward.
ConcreteOwl replied on at Permalink Best Answer Reply
ConcreteOwl
Your problem is that you have wrapped Main in single curly quotes instead of single straight quotes.
barbedwire replied on at Permalink Reply
Actually it is a single quote ( ' ), we have all the steps diarized in straight text files and simply copy/paste into projects.

Also checked here:
https://documentation.concrete5.org/building-website-concrete5/5-add... as well as other posts.

Exactly the same code.

Again, when running php 5.x no issue, php7 - rears it's ugly head.

I do appreciate the pingback..
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
No it isn't a single straight quote.
Please look closely and you will see that you have used single curly quotes (zoom in).
PHP 7 is less forgiving of such typo errors and this is why you are now seeing the error.
This error... assumed '‘Main’' is displaying single straight quotes wrapping single curly quotes.
That is the problem, you have copied and pasted single curly quotes and PHP 7 will not accept that.
ConcreteOwl replied on at Permalink Reply 1 Attachment
ConcreteOwl
The documentation you quoted is WRONG and I can see why you would think your code is correct.
The Forum Admins are unlikely to correct that typo error as they are not interested in supporting any legacy documentation.
Hell, it looks like they are not even interested in fixing this broken forum!
So please take my word for it, you must use single STRAIGHT quotes and not single CURLY quotes when writing code for PHP 7.
See the attached image!
JohntheFish replied on at Permalink Reply
JohntheFish
Its easy enough to double check either way. Delete Area('Main'); and re-enter it directly in the text editor. No copy paste.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
I have already tested this by changing single straight quotes to single curly quotes on an area name in a development site (local pc) and it immediately threw a syntax error in PHP 7.
JohntheFish replied on at Permalink Reply
JohntheFish
The intent of my post was more for @barbedwire to check the other way round. I know that you know the curly quotes will break it.