I'm trying to use php tag in a javascript function. But unfortunately its not working. I even used <?php but still not working. I checked php.ini file and there the short tag is already enabled.
Any sort of suggestion will be appreciated.
I'm trying to use php tag in a javascript function. But unfortunately its not working. I even used <?php but still not working. I checked php.ini file and there the short tag is already enabled.
Any sort of suggestion will be appreciated.
You should be aware that a php tag inside javascript gets evaluated on the serverside before it gets sent to the client. Example: If the php variable $feeling holds the string "love" "I love cheese." gets alerted.
<script type="text/javascript">
var text = "I <?php echo $feeling;?> cheese";
alert(text);
</script>
In that case the javascript code that gets returned from the server will look like:
<script type="text/javascript">
var text = "I love cheese";
alert(text);
</script>
I hope this will be of help to you to solve your issue.