Wednesday, November 23, 2005

Got PhP to work on Mac OSX

I had been stuck on reading an HTML form using PhP with the POST method when I learned about the declare globals problem and saw that the arguments to the POST, are teated like a perl associative array. To get "foo=..&" from the POST you use {$_POST['foo']} in the PhP script.

Secondly, provided PhP is enabled in the web server, ususally apache, one can use perl's opendir() and readir() to generate index pages on the fly. For example I have a dir of XML files and rather having to try xlink, which may not be implemented, to keep an index file up to date, I can make the index be the PhP file which reads the dir and spits out links to the files, or I can run the PhP file once whenever I edit the XML and save the output HTML file as the index.

No comments: