Link to home
Start Free TrialLog in
Avatar of burnedfaceless
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                                                                                                         
<settings>                                                                                                           
  <resolvedomains>false</resolvedomains>                                                                             
</settings>                                                                                                          
*/                                                                                                                   
                                                                                                                     
//listing 03.15                                                                                                      
                                                                                                                     
class AddressManager                                                                                                 
{                                                                                                                    
    private $addresses = ["209.131.36.159", "216.58.213.174"];                                                       
    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();                                                                                 
    $manager->outputAddresses((string)$settings->resolvedomains);                                                    

Open in new window

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

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

Is the part captioned /*sample xml the test data?
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of burnedfaceless
burnedfaceless

ASKER

Thanks Ray
10-4.  Hope it helped!