PHP in a .html file?



I was wondering how I could do PHP code in a .html file… Please help…


Hey @SrslyItsJoe, this page seems like a reasonably good overview of what you need to know, and there are other sources of information in this search. None of that is specific to Glitch; if you have a PHP project running properly (perhaps something Remixed from then everything PHP-related should Just Work.

Hope this helps!


hello! thank you for your response, i have tried doing <php and it said something about incorrect syntax?? let me get the exact message hold on-
here it is.
image @cori


I’m not sure linting, which is what generates those warnings / errors, will correctly recognize mixed php / html, although I haven’t tried it myself. You may just need to tolerate those messages for the time being (we hope to work on advanced Editor features like better linting in the future).

If you care to provide your project name folks could take a look to make sure that the problem you’re seeing really is just a linting problem.


so like how would i use php in my website then. for my index.html file


@cori u there lol cuz like i needa implement this codeeee


The linter warnings I mentioned won’t stop your code from working - they’re indicators that there’s something you might need to look at but in this case you’ll probably just have to ignore them.

Aside from that, everything you can do with PHP inside of HTML files anywhere else should work fine in Glitch. If you’re unsure how to do that I suggest reading through some of the information I pointed at as a starting place.

If you have specific questions, or you want to provide your project name so that folks can take a look at it, perhaps someone in the community might offer some guidance.


@cori can u help me w it. it just won’t work which is pissing me off :angry:

MOD EDIT: family-friendly language


image i get this on my website too.


Hey @SrslyItsJoe the problem you’ve indicated in your latest post is typically an issue with improperly closed <?php> tags causing PHP to think that that portion of the page is supposed to be interpreted as HTML and not as PHP. Mixed-mode PHP/HTML can be really hard to work with for this reason (among others).

I may be able to find some time to look more closely at specific problems you’re running into, as might other folks in the community, but it will be easiest for us to do so if we can see all your code, which you could enable by sharing your project name.

1 Like

@cori a bit off topic here, but can you remove the domain from my account?


@cori additionally, my project name is fancy-stock.