How to add PHP Code to a regular page


how can I add regular PHP Code to a page using RapidWeaver 7? I know that there’s under settings “Code” but if you place code there it’s for all pages, how can you choose one specific page?

You can do the same on a page by page basis in the page inspector. You can also add a HTML stack if you are using stacks as needed.

1 Like

Make sure you are using plain text also… no “smart quotes” (Don’t paste from work processors etc)

You can actually put html or php anywhere you can put text. Just select all your CODE and then “ignore formatting” on the format menu. So in effect you can put a snippet of code anywhere on a page, embedded in your text in addition to the areas provided in RW. Thus, you can use a php scripted button etc.

1 Like

Similar problem here:

I got this php code (to not refresh the JavaScript for Lastmodified date time).

It’s not enough to just put it into an HTML stack, should it be wrapped somehow?

$lastModified = filemtime($_SERVER[‘SCRIPT_FILENAME’]);
header('Last-Modified: ’ . gmdate(‘D, d M Y H:i:s T’, $lastModified));


with best regards, Omar KN, Stockholm, Sweden

Wrap it in php tags


Like @swilliam says…

First rule of PHP Club – “Wrap it in PHP tags.”


Your code here.


Also make sure you’re using standard single or double quotes in your code and smart quotes.

Hint: your code snippet above contains smart quotes.


Make sure the page extension is set to .php and not the default .html .

1 Like

Also make sure you’re adding the code to the “Prefix” area. Headers need to be sent before any actual page content. As has been mentioned, you’ll also need to wrap it in PHP tags.

1 Like

Yes the page is in php.
Corrected to standard single quotes.

Even when in Prefix RW doesn’t accept the code snippet.

I think I also had in the head , as a test, but x.

See here:

the page is this one:

What could be the reason that it breaks?


Your screenshots omit a lot. You’re taking screenshots that are too closely cropped. We cannot see where you’re placing the code in RapidWeaver. Give us more to work from.

The code showing up in the page is inside a stack and not coming from the “prefix” area.

I just placed your code in a page’s prefix area with the page extension set to PHP and previewed in Firefox and saw the last modified was set correctly. The code looks correct. Make sure all of your quotes are straight quotes, and that the code is in the page’s prefix area.



I had put the code into the Prefix, however the code was still in a HTML stack from testing earlier today and there was apparently a conflict.

Now it’s working.

The LastModified JScr allows me to see if the page I’m looking at is really the latest iteration.

Paul_WilkinsFormer Community Award Winner from

helped me with this script,
and I’ll put it there…

with best regards, Omar KN, Stockholm, Sweden