##
PHP/MapScript

MapServer's PHP environment (one of the many script environments for MapServer) is developed by
. It offers all the functionality of the CGI version, plus a whole new world of advanced technologies, to mention e.g.:

- dynamic maps: adding layers, classes etc to a map
- communication with other PHP modules, such as database or security modules
- local disk write, e.g. for developing desktop GIS applications like DMSolutions' MapLab and Chameleon.

Here I only describe the basic principle of using PHP/MapScript with MapClient. The greatest difference with the CGI version is that PHP MapScript doesn't have a template file. Everything the server sends back has to be programmed in the PHP script. This makes for more work in small applications, but gives much more flexibility in larger ones. This response can be organised in innumerable ways, but for MapClient I generally prefer to do everything with hidden variables in a form. I fill this form with all variables in the $_POST[] array:

    function mkhtml() {
        echo("<body>");
        echo("<form method=POST action=$_SERVER['SCRIPT_NAME']>");
        foreach($_POST as $key=>val) {
            echo("<input type=hidden name=$key value=\"$val\">");
        }
        echo ("</form>");
        echo ("</body>");
    }

This will simply echo back every submitted CGI variable. All new assigments to the $_POST array will be sent back automatically. With this method one serverFrame suffices for sending and receiving: all original content will be duplicated on return.