We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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

https://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

https://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.



93.7k
Accepted
answer

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