Dealing with apostrophes and quotes
-
I am trying to dynamically display/hide text based on whether a given variable is passed into the shortcode. I have the shortcode set up, a php if statement wrapping the variable to test whether it has content and it works… except if the content within the variable has a quote or an apostrophe. I get: Parse error: syntax error, unexpected ‘t’ (T_STRING). I understand the error but am wondering if there is anything that allows us to pre-process that variable text before it is eval’d.
i.e. the php code
if ('{test}') { echo '<p>My pre-wrap stuff then: {test}</p>'; }
fails with this version of the shortcode because of the apostrophe:
[demo test="Can't get this to parse."][/demo]
- The topic ‘Dealing with apostrophes and quotes’ is closed to new replies.