function __php__array_splice($arr, $idx, $length, $replace) { JS(<<<END_JS if (replace == undefined) { arr.splice(idx, length); } else { arr.splice(idx, length, replace); } END_JS ); }
function test2() { // $_COOKIE is read-only in JS. We'll use this javascript to set a real cookie. JS(' function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } createCookie( "mycookie", "data with spaces"); // Re-init the superglobal _COOKIE _COOKIE = ___load_cookies(); // undocumented. '); $stuff = $_COOKIE['mycookie']; echo "Test that \$_COOKIE can be accessed.<br>\n"; echo 'result: ' . ($stuff == 'data with spaces' ? 'pass' : 'fail') . "<br><br>\n\n"; }
function test4() { JS("\n for( var i = 0; i < 10; i++) {\n i ++;\n }\n"); echo "Test multi-line JS() code inside double-quoted string<br>\n"; echo 'result: ' . ($i === 10 ? 'pass' : 'fail') . "<br><br>\n\n"; }
function ___clone($o) { JS(<<<END_JS function c(o) { for (var i in o) { this[i] = o[i]; } } var d = new c(o); if (d.__clone) { d.__clone(); } return d; END_JS ); }