Can you use PHP in an HTML, CSS, JS template?

Can you use PHP in an HTML, CSS, JS template?

No you cannot! @arhanansari2009 is incorrect! You will need to create a PHP Web Server Repl in order to use PHP with HTML, CSS & JS. The reason for this is PHP is a server side/back-end language, while HTML, CSS & JS is statically hosted on the front-end.

4 Likes

You can use the <php> tag to use PHP in an HTML File.

This is an example of the usage of the <php> tag:

<?php
  echo "Hello World!";
?>
2 Likes

So I’ll create a project with PHP Webserver template and move my HTML, CSS, and JS code to it?

3 Likes

@MattDESTROYER … this time you are wrong. php can be embedded in html these days thanks to the trend of mixing stuff that were not supposed to be mixed … so it is possible, but should be done? I would say no. PHP place is in the back end.

1 Like

No, the poster is asking about the HTML, CSS & JS template, this will not work since this template is statically hosted. PHP is purely server side so you will need to use the PHP Web Server template to use PHP.

Screenshot

3 Likes

You are actually right, the html is actually a back end script and needs to run as back end and not as an html page.

3 Likes

Didn’t see this but yep, that’s exactly right, I’m assuming you probably got this sorted

3 Likes