GBdirect: Wap-Enabling a Website with PHP3 | Linux Today

GBdirect: Wap-Enabling a Website with PHP3

Written By
Web Webster
Web Webster
Apr 22, 2000

[ 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

Content-type: text/html

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.”

Complete
Story

Web Webster

Web Webster

Web Webster has more than 20 years of writing and editorial experience in the tech sector. He’s written and edited news, demand generation, user-focused, and thought leadership content for business software solutions, consumer tech, and Linux Today, he edits and writes for a portfolio of tech industry news and analysis websites including webopedia.com, and DatabaseJournal.com.

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.