5
I want to put PHP code in Javascript file, not HTML file. As for example here:
document.getElementById('lbljour').innerHTML = "Jour " + date_today;
With PHP code would look something like this?
document.getElementById('lbljour').innerHTML = <?php echo trad($f_lng,"Jour "); ?> + date_today;
Exactly, this way works. It didn’t work?
– Sergio
if the file extension is . js, it is not. but inside a. php file with javascript inside it
– pc_oc
Does not work. Yes is a. js file
– akm
You can create a global variable with the PHP content in the file that calls the
.js
. In the.js
you use the global variable.– Franchesco
You have already answered the question below with what I told you.. The . js file has a lot of code or just that line?
– pc_oc
Sorry for the comment... but what you’re doing at the very least results in a major security breach and an unorthodox way to achieve what you want. Javascript is a language that runs on the client and php is a language for the server...if this type of use is possible in javascript... then many services would be easily broken. The opposite is possible...ie by Php.
– chambelix