troubleshooting Question

Why is PHP Storm giving me an undefined constant error?

Avatar of burnedfaceless
burnedfaceless asked on
PHPXML
4 Comments1 Solution767 ViewsLast Modified:
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);                                                    
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros