I have the following code which I use to load the xml object but having trouble with variable value when retrieved from request.
$var1 = isset($_REQUEST['var1']);
$url = "http://xmlurl.com?_render=rss&td=$var1";
$xml = simplexml_load_file($url);
The above will actually send an incorrect value with the request to xml function.
If I manually hard-code the value on the url, it returns the correct records.
$var1 = isset($_REQUEST['var1']);
$url = "http://xmlurl.com?_render=rss&td=valuespecified";
$xml = simplexml_load_file($url);
What could I be missing?
isset()returns a boolean value (true or false). Try using the following code:This code will check to see if
$_REQUEST['var1']has been supplied. If it has not, the use the default value of default_value.