[mapserver-users] Sorta Off Topic - Putting PHP code in a CGI script?

nate parsons mistcat at eudoramail.com
Fri Mar 1 10:08:18 EST 2002


Tyler,

You might have seen the php version of perl's heredoc syntax:
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax
 
This lets you do something like the following:

$bob = $fred + $joe;
print<<<EOT

<TABLE>
<TR>
<TD>
Blah
</Table>
etc...

EOT
$bob = $fred - $joe;


in other words you can pretty much dump any html you want without print statements until the EOT or whatever characters you choose.  Note that the EOT must be at the beginning of a new line, not Tab indented to look nice in the source. =)  Also note that php will parse variables inside the heredoc block but there are some special rules you'll want to check out in the documentation. =)
--

On Thu, 28 Feb 2002 21:04:33   Paul Spencer wrote:
>Keep in mind that if you plan on using PHP/MapScript you will need to
>use PHP 4.0.6 and configure it as a CGI rather than a loaded module.
>
>Paul Spencer
>
>-----Original Message-----
>From: owner-mapserver-users at lists.gis.umn.edu
>[mailto:owner-mapserver-users at lists.gis.umn.edu] On Behalf Of
>Antti.Roppola at brs.gov.au
>Sent: Thursday, February 28, 2002 6:20 PM
>To: TMitchell at lignum.com; mapserver-users at lists.gis.umn.edu
>Subject: RE: [mapserver-users] Sorta Off Topic - Putting PHP code in a
>CGI script?
>
>
>You'd be better off calling your code from inside PHP
>if you really needed it. PHP is usually set up as a
>module in your server, so it's probably going to be
>respond faster than a CGI.
>
>As for the database, you could excise the CGI specifics
>in your database and call them from inside PHP as functions. Later on,
>you could re-write each function as native PHP. I do this to keep all
>database specific stuff out of my apps:
>
>function select_old ($sql) {
>	system(myoldcgoappmodified "$sql");
>	... stuff happens...
>	return $result;
>}
>
>function select($sql, $link) {
>	if (!($result = mysql_query($sql,$link))) {
>		echo("SQL query failed: $sql from $link<BR>\n");
>	}
>	return $result;
>}
>
>Antti
>
>-----Original Message-----
>From: Tyler Mitchell [mailto:TMitchell at lignum.com]
>Sent: Friday, 1 March 2002 8:10 AM
>To: mapserver-users at lists.gis.umn.edu
>Subject: [mapserver-users] Sorta Off Topic - Putting PHP code in a CGI
>script?
>
>
>Hi guys, I'm new to both CGI and PHP, but saw an example somewhere in a
>CGI script that allowed you to enter in raw HTML instead of putting in a
>separate PRINT command for it.  I cannot, for the life of me, find this
>example again though.  I though it would allow me to easy put in PHP
>stuff into my CGI script. I thought it went something like this:
>
>.......
>$query->start_html;
>print "bleh bleh";
>ECHO END >>>>
><B>This is bold</B>
><? PHP script stuff ?>
>END <<<<
>$query->end_html;
>
>Know what I mean?  I don't know what you call this and have searched and
>searched the docs with no avail :(
>
>
>
>


Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com



More information about the mapserver-users mailing list