hm, I am passing a custom field to php variable like this:
<?php
$body = '{body}';
?>
Problem: when the body has single quotes (‘) in it, it cannot be parsed (eval() parsing error in core.functions.php)
I already tried this one, but it doesn’t solve the problem:
<?php
$myVar = <<< EOD
{my_ee_var}
EOD;
?>
anyone got an idea?
TIA!
Yes, nesting quotes is going to cause you problems; you’ll need to do some sanitization on the data so that you don’t run into this. You might consider moving this into a plugin so that you can work with it more comprehensively.
In any case, this is beyond what we can offer as technical support - did you want me to move it to the Plugins forum (if you’re going to go that route) or How To?
You could also use output buffering instead of HEREDOC, which will prevent PHP from attempting to parse variables. Consider the content:
I made $15 selling peanuts!
If you put that into a HEREDOC without escaping the dollar sign, you’ll get an unexpected $end syntax error. Output buffering, however, doesn’t parse anything.
<?php ob_start(); ?>
{example_variable}
<?php
$str = ob_get_contents();
ob_end_clean();
?>
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.