Hint: you can’t.
PHP is server side. The code runs before the page is even sent to your browser.
Javascript is client side. It is executed after the server sends you the page.
To get your code working would require to:
– Run PHP code on the server, send you the page.
– Run Javascript, “edit” the page
– Request the server for another version of your page, now with the code.
You can, however, directly add it into your HTML.
Just use The file is at the location <?php SomeMethod(); ?>.
1
solved PHP syntax within HTML code [closed]