Avatar of burnedfaceless
 asked on

Why is PHP Storm giving me an undefined constant error?

I am outlining chapter 3 of PHP Objects, Patterns, and Practice. What an incredible book.

PHP Storm is giving me the error of undefined constant simple xml and undefined function load file.

I want to be able to open this file in a browser (I'm doing one file a chapter with comments for notes). I haven't worked with XML and don't understand what is going on here.

Would someone please explain what is going on, but more importantly how to get it to load in a browser? Should I comment that line out?

//listing 03.14                                                                                                      
/*sample xml                                                                                                         
//listing 03.15                                                                                                      
class AddressManager                                                                                                 
    private $addresses = ["", ""];                                                       
    public function outputAddresses($resolve) {                                                                      
        foreach ($this->addresses as $address) {                                                                     
            print $address;                                                                                          
            if ($resolve) { //here is PHP making a judgement call to answer "TRUE" in an interaction with a string   
                print " (".gethostbyaddr($address).")";                                                              
   //listing 03.16                                                                                                   
    $settings = simplexml:load_file(__DIR__."/resolve.xml");                                                         
    $manager = new AddressManager();                                                                                 

Open in new window


Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
Ray Paseur

I think line 27 should be simplexml_load_file instead of simplexml:load_file.

Is the part captioned /*sample xml the test data?
Ray Paseur

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks Ray
Ray Paseur

10-4.  Hope it helped!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy