[mapserver-users] Mapserver & PHP scripting

Julien-Samuel Lacroix jlacroix at mapgears.com
Mon Apr 7 10:27:18 EDT 2008


Hi,

You will have to load the PHP parser to execute your PHP code. This 
cannot be done by MapServer CGI. I don't think you could redirect your 
output to the PHP parser directly via Apache either. What you could do 
is hit a PHP page that would act as a proxy for your CGI application. 
Your PHP code would then be executed without any problem.

Here's an example that include your MapServer CGI output and execute it. 
You  can access it directly with the exact same arguments that you use 
with your CGI request:

<?php
// You need
// allow_url_include On
// in your php.ini

// Re-Build your CGI URL from the PHP URL
foreach($_REQUEST as $szKey => $szValue)
{
     $szCGIParams .= "$szKey=$szValue&";
}
include("http://localhost/cgi-bin/mapserv.exe?".$szCGIParams);

?>

Julien

Brent Wood wrote:
> Hi,
> 
> Quick question, I'd like to add some php functionality to a simple CGI
> mapserver application with an html template file.
> 
> I'd much prefer not to rewrite it in mapscript, everything else works perfectly
> & the PHP I want to use is not for the mapping side of things, but to provide
> database driven pick lists & data extract tables etc.
> 
> The mapserver CGI output recieved by a browser, & viewed with "view source",
> includes the PHP code in the html template, but it is not parsed as php.
> 
> So my question is, is there a way to have the html output generated by CGI
> mapserver passed through php & properly invoked? Presumeably by apache prior to
> sending it on to the client.
> 
> 
> Thanks,
> 
>    Brent Wood
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 

-- 
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/


More information about the mapserver-users mailing list