name(); } else { $user = "test"; } $string = << ciao = 0; function onLine() { ciao = ciao + 1; console.log(ciao); console.log("onLine"); var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://62.171.139.86/allerta/online_check.php?user=$user'); xhr.onload = function () { if (xhr.status === 200) { console.log('Text ' + xhr.responseText); } else { console.log('Request failed. Returned status of ' + xhr.status); } }; xhr.send(); } function offLine() { console.log("offLine"); } function check() { console.log("dfcghfhdt"); var i = new Image(); i.onload = onLine; i.onerror = offLine; i.src = 'https://www.google-analytics.com/__utm.gif'; } EOT; echo($string);