php - Unable to use DOMDocument in Symfony -




i have been unable use domdocument in symfony. after digging around, found problem might not have php xml extension, thought absurd because, despite no being able use domdocument, can use symfony's domcrawler, uses similar domdocument. well, after looking through crawler's source code, found uses like

$dom = new \domdocument('1.0', $charset);     

instead of usual

$dom = new domdocument('1.0', $charset); 

does know difference between two, , why 1 works , other doesn't in symfony?

because in symfony use namespace in each class. , because have declared namespace in class need inform php namespaces of each class want use. if not declare namespace of class using, php think class in same namespace current class.

so backslash "\" in code: new \domdocument() there informe php want use domdocument class "global" namespace. if want use datetime object need use backslash when instantiating datetime object.

another solution declare keyword use. exemple:

use \domducment; 

and in code instanciate without backslash: new domdocument()





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -