Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

In a template I was working on recently, I started to get PHP Notices about undefined constants FALSEOR and FALFALSEORFALSE:

A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant FALSEOR - assumed 'FALSEOR'
Filename: libraries/Functions.php(683) : eval()'d code
Line Number: 205

[and]

A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant FALFALSEEORFALSE - assumed 'FALFALSEEORFALSE'
Filename: libraries/Functions.php(683) : eval()'d code
Line Number: 260

The template code that generated these messages was:

{if STYLE}
    <tr>
        <td>Style</td>
        <td>{STYLE}</td>
    </tr>
{/if}

{if YEARBUILT}
    <tr>
        <td>Year Built</td>
        <td>{YEARBUILT} {if YEARBUILTSRC}({YEARBUILTSRC}){/if}</td>
    </tr>
{/if}

The variable names in all caps are variables provided by a plug-in. It is possible that they may have empty values, but I haven't been able to produce a case where any would be undefined [in the array consumed by TMPL->parse_variables() in the plugin].

I'm stumped as to why they're being parsed as PHP constants... And even so, I don't see where the strings 'FALSEOR' or 'FALFALSEORFALSE' are being created. Those strings don't appear anywhere in the EE source [that I can find], and none of the template variables are so named.

Should I report this as a bug? Has anybody seen something like this before?

share|improve this question
1  
Without the plugin code, it is very difficult to debug this. Also, the error says line 205, yet your example only has a few lines. If you look at the other line for the error (functions.php line 683) it is the eval() function. Maybe you're generating some PHP that fails? –  GDmac Dec 27 '12 at 11:09
2  
In the past I have resolved a similar error by using {if STYLE != ''} instead of just {if STYLE}. Whilst I believe that both should be valid, I have experienced this same problem. Simply adding != '' solved it for me. Let me know if this helps. –  Lea Hayes Dec 27 '12 at 13:02
    
Yes, please post the code for the plugin that's generating these variables (or a link to that code). It is surely the culprit. –  Derek Hogue Dec 27 '12 at 13:39
    
Michael, did you ever resolve this? If yes, can you post your fix? Did Lea's above suggestion of {if STYLE != ''} help? –  Anna_MediaGirl Jan 17 '13 at 2:56
    
This is note quite resolved, but unfortunately I'm not able to share the code of the plugin at the moment. I can't reproduce the issue consistently enough to judge whether {if STYLE != ''} is a solid fix, but it certainly doesn't hurt. Really, I'm mostly curious where FALSEOR or FALFALSEEORFALSE are coming from, as I can't find them in the code, and they're definitely not in the plug-in's data array. –  Michael Rog Jan 21 '13 at 22:34

1 Answer 1

up vote 1 down vote accepted

PHP has four values when it evaluates an if condition, true, truthy, false, and falsey.

http://www.phabricator.com/docs/phabricator/article/PHP_Pitfalls.html

Depending on what you're getting back from your add-on, or the add-on's datasource (especially if the data from the source is inconsistent) PHP's conditional logic may act strange if you don't check the value explicitly (ex: STYLE != '').

Also since it sounds like you'll be checking for empty strings. I might take an additional step and fashion your IF statements like this:

{if "{STYLE}" != ""}
   ...
{/if}

This will ensure that "STYLE" is always interpreted as a string rather than being evaluated as an object or PHP reserved value

share|improve this answer
    
Patrick, I suspect you're very much on the case here. The Pitfalls page is great, and would explain what might be happening within the code. The tip to quote the if-argument is likely what will clear this, and let's hope it does ;) –  narration_sd Feb 19 '13 at 20:07
    
So far, explicitly checking the string value is working. Thanks for the additional info/link Patrick! –  Michael Rog Feb 21 '13 at 22:20
    
No problem Michael! –  Patrick Pohler Feb 28 '13 at 15:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.