I am having issues inserting a php variable into my javascript code. I have a php page that calls javascript code using a tag. Doing just that, I am able to successfully run the javascript on the php page. However, the javascript code breaks as soon as I try and insert a php variable.
One method I tried was writing the script code like normal, and inserting into the script, but that breaks the page.
$(document).ready(function() {
$('#calendar').fullCalendar({
defaultDate: this.date,
editable: false,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: <?php
$em = 'edfetsko@gmail.com';
echo $em; ?>,
start: '2015-02-01'
}]
});
});
My other attempt was to try and contain all of the above code (including tags) as a php string and then print/echo it to the page, but that didn't work either (for some reason it just printed '0').
What is the best way to achieve what I'm going for?