Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Error when calling simplexml_load_string

Hi! I'm trying to parse a XML string into an object by using simplexml_load_string. However I get this error:

$xml = new simplexml_load_string($tp_response);

FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class 'PhalconRest\Models\simplexml_load_string' not found in /var/www/html/slack/models/Webconn.php:134

Am I missing a reference to use PHP functions directly?

Thanks! Christian

Is the simplexml extension compiled/enabled?

php -mi simplexml

http://php.net/manual/en/simplexml.installation.php

Why use it as class, its a plain php function?

Just do

$xml = simplexml_load_string($tp_response);

Hi! Thanks for your reply, I do have it installed. ... shmop SimpleXML sockets ...

Is the simplexml extension compiled/enabled?

php -mi simplexml

http://php.net/manual/en/simplexml.installation.php

That's exactly what I did:

if ($responseCode == 400) { $xml = new simplexml_load_string($tp_response);
.... }

Why use it as class, its a plain php function?

Just do

$xml = simplexml_load_string($tp_response);

My bad... was using "new" for some reason.

Need more coffee.

thanks everyone.



82.8k
Accepted
answer

Mistakes happen. You can mark the thread as solved now :)