PHP and ASP pages

RocketCake not only is able to create static HTML websites, but also dynamic websites created by PHP or ASP. This pages shows a short overview about how to do that, and it will focus on PHP, but it is basically the same with ASP websites.


In order to use PHP, you need to know HTML as well as how to program PHP. It is a programming language after all. It could be a good idea to read through some real PHP tutorials on the web (there are a lot of them), because explaining it here is quite out of scope.


Getting started


Using PHP, ASP and JavaScript is quite simple in RocketCake, and there are several ways to do this. For PHP, simply name your pages/files with a .php extension, not .html which is the default. To do this, change the 'FileName' property in the property window of the page when selected in RocketCake to something ending with '.php', instead of '.html'.


By using either the 'PHP Code' element (Insert -> PHP code), you can enter php code anywhere on the page. Double click it and enter for example this code to see if it works:


echo ('hello world');


Additionally, you can use the menu 'View -> HTML Code of Page' to insert PHP code before and inside the header of the website.



Inline PHP Code

At any place on the website you can also very easily add inline PHP code without using the code element, if you have the professional edition of RocketCake.

You only need to enclose it in the PHP tags "<?PHP" and "?>". For example just write something like


<?PHP echo ('hello world'); ?>


And RocketCake will add this code at the place where you typed it. This will only work if the name of the generated webpage has the extension .php. And it will only run if started from a webserver with PHP support.



Making it run


To test your PHP code, you need to run the page from a (local) webserver. Use the 'publish to local disk' feature of RocketCake (Menu: Publish -> 'to local disk') to write out the final .php file and then copy it to a webserver to test it out. If you only do the 'preview' instead, RocketCake will add a .html to your website and show it as it wasn't php.




Copyright © by Ambiera e.U.