Re: Help translating PHP5 code to PHP4.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/7/2011 8:16 AM, Marc Guay wrote:
> Hi folks,
> 
> I've stumbled into a project involving a server running PHP4 without
> cURL.  The script fetches data from an XML webservice and deals with
> it.  Is http://ca2.php.net/xml_parser_create the place to start?  Any
> tips (besides updating PHP)?
> 
> Here's an example of the PHP5 code:
> 
> $url = "http://www.domain.com/webservice.php?var=foo";;			
> $ch = curl_init($url);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> $val = curl_exec($ch);
> curl_close($ch);
> libxml_use_internal_errors(true);
> $xml = simplexml_load_string($val);
> $errors = libxml_get_errors();
> 
> if (!($errors)){
> 	$myvariable = $xml->attributes()->value;
> }
> else{
> 	// deal with errors	
> }
> 

Here is an example that is in the PHP manual

http://us.php.net/manual/en/function.xml-parser-create.php#38739

The only modification that you will probably have to make is to set the
following in your php.ini file.

allow_url_include = On
and/or
allow_url_fopen = On

This would allow fopen to open the external URL and grab the data returned.

Jim Lucas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux