Javascript - how to echo php in javascript -


How can I get php properly inside javascript?

  var timeDiff = 60-20; If (Timediff <= 60) {var stamp = timeDiff & lt ;? Php echo $ this- & gt; __ ('second first'). '.'; ? & Gt ;; }  

console error:

Unwanted syntax error: unexpected identifier

This resonates 'second first' Chrome source, though after error.

Just wrapping the material that you are echoing should do it, e.g.

  var stamp = timeDiff & lt ;? Php echo json_encode ($ this-> __ ('seconds ago'). '.'); ? & Gt ;;  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -