Debugging SimpleXML Objects

SimpleXML is pretty much the de facto standard for dealing with XML in PHP. The biggest problem with SimpleXML is that it is a pseudo-object that you can’t print_r() or var_dump() to see what’s going on. I recently ran into a situation where it would have been super nice to dump the entire object and see what was going on. Fortunately my Google-fu was...

Read Full Article →

Parsing SOAP responses with SimpleXML

We recently discussed parsing XML with SimpleXML and since that writing I ran into a situation where I needed to parse a SOAP response. As it turns out, SOAP responses are a totally different beast when it comes to parsing them with SimpleXML. SOAP responses contain namespaces on some if not all of the nodes and SimpleXML doesn’t really care for that when using...

Read Full Article →

How to calculate Independence Day observances

On this 238th anniversary of the United States of America, I felt it appropriate to post an article on how to determine what day the July 4th National Holiday is observed on. There are two rules to the observances. First, if the holiday falls on a Saturday, it is observed on the Friday before. If it falls on a Sunday, it is observed on...

Read Full Article →

How to parse XML with SimpleXML

Parsing XML in PHP couldn’t be easier thanks to the SimpleXML extension. SimpleXML allows you to read in an XML string, verify that it is in fact XML and can create an object that you can interact with by way of the node names in the XML.The SimpleXML extension also allows you to write out XML but for the sake of simplicity, I am...

Read Full Article →

Checking your IMAP email using PHP

I have an upcoming freelance project coming up that includes checking an IMAP email account as well as working with XML in PHP. Let’s talk about connecting to an IMAP account in PHP, don’t worry, I’ll discuss parsing XML next week ;) For the sake of example, we’re going to connect to a Gmail account: $hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; $username = 'example@gmail.com'; $password = 'password';...

Read Full Article →