For a complete tutorial and reference manual on Pike, see http://pike.oav.net/.
The Pike tag allows you to easily insert Pike code into your HTML page à la PHP. This is a good way of learning Pike if you have a PHP background or if you want to do things very easily and don't worry about perfect results.
To do this, you have to load a module in your server. Just select Load module in the CIF. and click the "Pike tag" image. Then hit save and create an .html file where your public web files are. Since everybody tells me that PHP is easy, which is why it's so popular, I took the PHP examples and converted them to Pike. Here is the result:
Example 6-2. The PHP documentation as a Pike tag.
<html> <body bgcolor="#FFFFFF"> <h2>Escaping from HTML</h2> <p> There is one way of escaping from HTML and entering "Pike code mode" <br /> <Pike> output("This is the simplest, and SGML processing instruction"); </Pike> </p> <h2>Instruction separation</h2> <p> Instructions are separated the same as in C or Perl: terminate each statement with a semicolon. The closing tag (container, in fact) also implies the end of the statement, so the following are equivalent: <br /> <Pike> output ("This is a test"); </Pike> <br /> <Pike> output ("This is a test"); </Pike> </p> <h2>Comments</h2> <p> Pike supports C, C++ but not Unix shell-style comments. For example: <Pike> string tests = "This is a test<br />"; // this is a one-line C++ style comment /* This is a multi line comment yet another line of comment */ tests += "Yet another test"; return tests; </Pike> </p> <h2>Melding RXML and Pike</h2> You will never see this in PHP. [1] This will create a .gif image of 1-2-...-255. This took 0.4s on my Duron 750 the first time and 0.1s after. <p> <gtext scale=0.5> <Pike> string output = ""; for(int I = 1; I < 255; I++) output += I + "-"; return output; </Pike> </gtext> </p> </body> </html> |
The problem with using this is that you will soon see it is not powerful:
The code will become an ugly mixture of data and code even if you use an object orientation method. The more your project grows, the less you will be able to produce something useful.
The URL will require plenty of those "&" symbols and you will have a lot of files without real organization.
The performance will not be the best.
This can be considered as a security risk for servers that are opened to unknown users (eg. public web servers).
The next step is to write your first Pike script.
[1] | In fact you can... just compile PHP for Caudium :) |