Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Tip: hiding PHP scripts in CD preview

I use php in .html files, so I can use preview. However, the php scripts show up quite messy in the html output, as anything after the first ">" symbol in the php section is shown by the browser.

My solution:
<!--
<?php
echo "--\>";
// the real php script comes here....
// -->
?>

Now I only see "?>" instead of the whole script.

Adriaan van den Brand
Friday, September 13, 2002

That's pretty neat, with one small drawback. If you're manipulating cookies in php then you need to set them before any html is passed back to the browser. So if you have <!-- as the top line then it'll be outputted before you can get to the cookies. Hey, it's only a small drawback.

John C
Friday, September 13, 2002

Hi John, I think there are some work arounds for your cookies too:
-1. associate .php with internet explorer and type HTML document
-2. patch Citydesk: replace unicode text "<!-- Published by  ... -->" into "<?php //...?>"

1) is ok if you use .php extensions
2) is also suitable for .html, only I'm not sure if Joel is happy with it... ;-)

(I hope next version of Citydesk will have a way of dealing with it in a neat way!)

Adriaan van den Brand
Friday, September 13, 2002

*  Recent Topics

*  Fog Creek Home