Category Archives: PHP

How to Check if a Date is More or Less Than a Month Ago with PHP

Let’s say we have the following problem: we have to check whether a date is more than a month ago or less than a month ago. Many developers go in the wrong direction by calculating the current month and then … Continue reading

Posted in micro tutorial, PHP | Tagged , , , , , , , , | 1 Comment

Object Cloning and Passing by Reference in PHP

In PHP everything’s a reference! I’ve heard it so many times in my practice. No, these words are too strong! Let’s see some examples. Passing Parameters by Reference Clearly when we pass parameters to a function it’s not by reference. … Continue reading

Posted in micro tutorial, PHP | Tagged , , , , , , , , , , , , | 3 Comments

Some Notes on the Object-oriented Model of PHP

PHP 5 introduces interfaces and abstract classes. To become a little clearer, let us see their definitions. Interfaces Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods … Continue reading

Posted in PHP | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , | 5 Comments

Thing to Know About PHP Arrays

Consider the following case. We have an array with identical keys. $arr = array(1 => 10, 1 => 11); What happens when the interpreter reaches this line of code? This is not a syntax error and it is completely valid. … Continue reading

Posted in micro tutorial, PHP | Tagged , , , , , , , , , , , , , , , , , , | Leave a comment

PHP: Does SimpleXMLElement have toString() method? No, better use asXML()!

SimpleXML is a PHP extension that “provides a very simple and easily usable toolset to convert XML to an object” [1]. Thus you can pass a link to an XML file and SimpleXML will return an object. $xml = simplexml_load_file(’path_to_the_file’); … Continue reading

Posted in PHP | Tagged , , , , , , , , | 1 Comment