Yes. Any page can be published as a .php page with Page Extension, in Inspector > Page Settings > Advanced Options. PHP code on that page then runs on your web server. Your hosting needs to support PHP (EverWeb + Hosting does), and the code only runs on your published website, not in Preview.
EverWeb features that already use PHP
You don't need to set anything for these. They work on EverWeb + Hosting and on other hosts that support PHP:
- Contact forms, and the Contact Forms Enhanced add-on
- The Stripe Payment widget
- Membership Sites. Pages with membership levels are published as .php pages automatically
On another host, we recommend PHP 8.2 or later. Your host can tell you which version your website uses. The search box doesn't need PHP: see Add a search box to your website so visitors can find any page.
Publish a page as .php
- Select the page in the page list.
- Go to Inspector > Page Settings and open Advanced Options.
- Set Page Extension to php.
- Add your PHP code (see below).
- Choose File > Publish Entire Site, so links on your other pages point to the new address.
- Open the published page in your browser to test it.
Where to put the code
| The code is | Put it in |
|---|---|
| Code the service says goes in the page's head | Inspector > Page Settings > Head/Footer Code, in Head Code |
| Code that shows something in one spot on the page | An HTML Snippet widget, with Embed Option set to Direct Embed |
Direct Embed places your code straight into the page. With the other two options, EverWeb may keep the code in a separate frame, and it may not work as PHP there. For how the HTML Snippet widget works, see Add a booking calendar, Instagram feed or other outside code with the HTML Snippet widget.
Code that has to run before anything else on the page, such as some login systems, may not work in Head Code. That's because the start of the page always comes first. If that's the case, ask the code's maker whether it can run from a separate .php file instead.
Before you change a page that's already online
- The page's address changes, for example from about.html to about.php. Bookmarks and Google still point to the old address. On EverWeb + Hosting, type the old full address in the box under Redirect an existing URL on your website to this page (in Advanced Options). Visitors who use the old address then reach the new page.
- The old .html file stays online. Publishing never deletes files. See I deleted a page in EverWeb but it's still online.
- Leave your home page as html if you can. If you change it, the address becomes index.php, and many servers keep showing the old index.html first. If you need to change it, contact us (or your host) to remove the old file.
Your own PHP files
Some services give you a whole .php file as well as code for your page.
- On another host: upload the file with your host's file manager or FTP, into a folder of its own. Link to it from EverWeb with its full address. EverWeb won't overwrite or delete it when you publish.
- On EverWeb + Hosting: there's no FTP login, so contact us before you start. Tell us what the file is for. EverWeb + Hosting is made for websites built in EverWeb, so a separate PHP program such as a forum or a blog system isn't something we usually host.
You don't need to ask your host to run PHP inside .html pages, as older advice said. Page Extension does the same job and is easier to undo.
What we can help with
We can check that EverWeb publishes your page as .php, with your code on it. We can't write, change or debug PHP code from other companies. If their code doesn't work, contact the company that gave it to you. Only use code from people you trust: PHP runs on your server and can change your website.
