Top White Papers
GBdirect: Wap-Enabling a Website with PHP3Apr 22, 2000, 14:52 (0 Talkback[s])
(Other stories by Mike Banahan)
[ Thanks to Mike Banahan for this link. ]
"As a hobby project (mainly to learn the Qt widget set) I had already built a moving-map GPS package to run on a Linux laptop while driving. ... By the end of January a rough prototype of Somewherenear had been built. The location data is stored in a MySQL database and distance-based searching performed very simply by using SQL 'select' statements with 'where' clauses that limit the latitude and longitude of the items sought. ... We had always planned to hook the database into location-aware devices. ... Our goal was to be able to go to a strange town, press the 'nearest pub' button on whatever the device was and to get a map showing establishments nearby, together with visitors' ratings."
"I decided to replace the template language with php3 but to enforce a rigid separation of responsibilities. The CGI scripts must do all the data management, the templates must deal with presentation only. This rule is an absolute winner and has proved to be hugely effective. We still write the CGI programs in C++. The CGI program runs on response to every incoming query and is easily fast enough to fill our data pipe without having to resort to trickery like Apache modules or fastCGI. Each execution of the CGI inspects the incoming form and uses that to decide which presentation template should be used. These presentation templates (nothing to do with the C++ 'template' construct) are php3 pages. The CGI program's output is essentially a long list of php3 data definitions..."
"After spitting out the data, the CGI program opens the php3 template file and tacks it onto the end of the data definitions, so it's acting much like the 'cat' command. The whole pasted-together chunk is sent through a pipe into the php3 interpreter and the output of that is also piped asynchronously through 'weblint'; if weblint picks up any errors, it emails us to warn that we are generating bad HTML. ... After we got the HTML site going, the next task was to WAP it up. The first concern was how much we would have to hack php3 to tell it not to emit a first line that says
Although I couldn't find it documented anywhere, I found to my deep and abiding joy that if you use the php3 header() function to output a different content-type header, that suppresses the default."
0 Talkback[s] (click to add your comment)