When using a PHP proxy, it is important to check whether it has received relevant parameters from the calling page. Some parameters might be required and some might be considered optional.
When checking for missing data, you could allow the PHP page to assign default values to missing data. This can allow you to configure default values in the PHP page for infrequently used parameters and allow the defaults to be overridden if the caller decides to send the parameter in the proxy call.
For example, if your proxy is designed to retrieve pictures, you could have your proxy automatically decide that the picture size will be 320x240 unless calling page wants something differently. Perhaps sending something like "&height=640&width=480" would cause the proxy to return images at 640x480.
Using default values for required values can be helpful in testing because the PHP page can be called without having to go through an html page. This is also helpful for testing html pages that call the proxy by allowing the proxy to be called without supplying parameters.
//-- This attempts to assign variable $loc the value from parameter "loc" if page is called with GET method
$loc = $_GET["loc"];
//-- After the attempted assignment, this line checks if $loc was actually set to a value. If it was, it keeps its assigned value, otherwise it is given a default value..in this case a default zip code of "48186"
$loc = (isset($loc) ? $loc : "48186");
I have proxy that pulls a Yahoo! weather feed. It uses "loc" as a parameter for the local zip code. If it is not supplied, the proxy uses "48197" to retrieve the data.
//-- This link specifies a zip code of "48154" and gets weather back for Livonia
http://myfavoriteplaces.org/movies/scripts/_getweather.php?loc=48154
//-- This link omits the zip code and gets weather back for Ypsilanti using "48197" as the default
http://myfavoriteplaces.org/movies/scripts/_getweather.php
This type of checking is also good for determining if this page was called from another page or if a visitor is trying to access the page directly. Some php files are not supposed to be run by themselves, so checking for valid values can allow the script to fail gracefully.
For example the following would let the user know that they shouldn't run this file directly and then stops running the script on the page.
if (!isset($loc)) { die ("You cannot access this file directly..."); }