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

Puneet Kishor pkishor at GeoAnalytics.com
Thu Feb 28 18:07:08 EST 2002


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

first, PHP is kinda CGI... usually two CGIs don't co-exist. One is more than
enough to do the job, and they get in each other's ways.


> I thought it went something like this:
> 
> .......
> $query->start_html;
> print "bleh bleh";

in the case of the above two statements, you have a PHP block, and these are
PHP commands. For example, the print function is writing out "bleh bleh".


> ECHO END >>>>
> <B>This is bold</B>
> <? PHP script stuff ?>
> END <<<<


in the above 3 statements you are using the Perl-kinda heredoc method of
writing a block of text (I don't know PHP well enough... didn't know you
could do this in PHP as well). Then, within the block of text that you have
escaped from the PHP block by using ECHO END >>>> you are once again
escaping back to PHP using <? ... ?>. This is a bit convoluted. Do one or
the other, unless you have good reason to.

In Perl you can use embperl to make it behave PHP/ASP like so you can embed
Perl code in arbitrarily inside text.

Hope the above doesn't confuse you even more. Other's on the list might be
able to explain better, or perhaps you might want to elaborate what you
actually want to do.

pk/



More information about the mapserver-users mailing list