I am using the shortcode execute plugin in wordpress.
This simply allows me to write shortcode like this [email_spamproof]
But I am trying to echo a script. Please see below...
<?php
echo '<script type="text/javascript">
<!--
// spam protected email
emailE=("enquiries@" + "example.co.uk")
document.write('<a title="E-mail Example" href="mailto:' + emailE + '">' + emailE + '</a>')
//-->
</script>
<noscript>
<span class="spam-protected">Email address protected by JavaScript. Please enable JavaScript.</span>
</noscript>';
?>
Now you can probably see my problem already.
Usually when I echo stuff it goes like this... echo 'hello';
And you break the string using the same apostrophes
- like this...echo 'hello ' . php_name() . ' and friends'
My Problem
The script also uses a similar method by adding script variables into the string, but these script apostrophes will get confused as PHP apostrophes, and break the echoed string.
How can I avoid this?
Thanks
The right code:
<?php
echo "<script type='text/javascript'>
<!--
// spam protected email
emailE=('enquiries@' + 'example.co.uk')
document.write('<a title='E-mail Example' href='mailto:' + emailE + ''>' + emailE + '</a>')
//-->
</script>
<noscript>
<span class='spam-protected'>Email address protected by JavaScript. Please enable JavaScript.</span>
</noscript>";
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With