I want to know this: the code written
var soder = document.getElemntsbyId("id"); soder.innerHtml = "text";
everything works fine, but it’s worth stuffing into innerHtml
soder.innerHtml = "<?php echo 'text' ?>";
then is not displayed. How to fix it? Or how to write the code correctly so that the browser reads the PHP code.
Answer 1, authority 100%
The fact is that there are tags, and the browser does not display them.
By the way, you have a typo in getElemntsbyId.
var soder = document.getElemntbyId("id"); var php_text = document.createTextNode('<?php echo "text";?>'); soder.appendChild(php_text);
It should work.
Answer 2, authority 100%
What code do you expect to see? The browser accepts everything in <> like html tags and because <?php echo ‘text’ ?> he does not know, he just skips it and does not show anything, naturally he is not going to process the php code. If you just want to output the code as text, then you need to write this
<?php echo 'text' ?>
And if you want to display the word text using php, then this can only be done on the server.
Maybe there is an error in the PHP code itself, or try to put the PHP code into a variable as just text and then display the value of the variable in innerHTML (maybe JS cuts out some characters or interprets them in its own way).
<?php text ?>
What did you mean by that? ) In general, this should give a php error, unless you have a text constant.
<?php echo "text";?>
var soder = document.getElemntsbyId("id") soder.innerHtml = "<? php echo htmlspecialchars(category ($cat_number));?>"
What did you want from this post? How would a browser execute PHP functions in an html document?