tags:

views:

236

answers:

2

Hi I've got a script which works fine on our development server but dies on the clients server.

error_reporting(E_ALL);
if (function_exists('simplexml_load_file')) echo "function exists";
if (file_exists('test.xml'))
{
echo("<hr>just about to read local xml file :".__LINE__); 
$xml = simplexml_load_file('test.xml');   // dies here

In Perl you can trap such errors with eval, is there anything equivalent in PHP?

A: 

Depends on the manner in which the function fails.

In the case of simplexml_load_file(), the error info is well documented

On errors, it will return FALSE.

and

Produces an E_WARNING error message for each error found in the XML data.

and

Tip

Use libxml_use_internal_errors() to suppress all XML errors, and libxml_get_errors() to iterate over them afterwards.

And, you can always set your own error handler or use the (troublesome) error suppression operator.

Peter Bailey
PeterIt never returns from simplexml_load_file, tried your suggestions to no avail
zzapper
Is their server PHP 5?
Peter Bailey
yep, their sysadmin is on the job but also having problems
zzapper
I guess just get what info you can from their error logs. What error_reporting level are you using on their server?
Peter Bailey
A: 

Sysadmin:- I've briefly turned on verbose error reporting and it's come back with this:

Fatal error: Cannot clone object of class SimpleXMLElement due to 'zend.ze1_compatibility_mode' in

http://archives.devshed.com/forums/php-108/simplexml-problem-982459.html

This configuration can be overridden on a per site basis with a .htaccess file directive http://www.activecollab.com/forums/topic/616/

this solved the problem. But why couldn't I turn on this level of error reporting from within my script?

zzapper