Category Archives: micro tutorial

How to Setup Different Error Messages for Each Zend Form Element Validator

Anyone who has worked with that has come across this problem. I’d like to show different error message on each validator attached to a Zend_Form_Element. Let’s say we validate an text input field. We want it to contain only digits, … Continue reading

Posted in micro tutorial, zend framework | Tagged , , , , , , , , | 1 Comment

PHP: Don’t Call the Destructor Explicitly

“PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++”[1] says the documentation for destructors, but let’s see the following class. class A { public function __construct() { echo ‘building an object’; }   … Continue reading

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

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

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