A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Tag Archives: PHP

LAMP’s success is spelling its own doom?

Here is a very interesting post regarding LAMP (Linux, Apache, MySQL and PHP). I agree with the post all the way. So whats the problem here? Well I think one of the key issues is that LAMP focus on solving … Continue reading

Posted in General | Tagged , , , | Leave a comment

How to get the a date before current date in PHP

Given 2008-01-31 as the current date and the value of “$days_before” is 2, the code will echo 2008-01-29. The date 2 days before the current date. $days_before = 2; $current_date = date(’Y-m-d’); $str = strtotime($current_date)-(86400*$days_before); //1 day has 86400 echo … Continue reading

Posted in General | Tagged | Leave a comment

Get Difference Between 2 Dates Using PHP

Here is how you get the number of days between two dates.   function getdays($day1,$day2) { return round((strtotime($day2)-strtotime($day1))/(24*60*60),0); } $begin = date("Y-m-d"); // we set today as an example $end = "2007-01-29";   echo getdays($begin,$end).’ days’; This was taken from … Continue reading

Posted in General | Tagged | Leave a comment

Simple PHP + AJAX + XML Chat Tutorial

A short but complete tutorial on how to write a Chat Application using PHP, AJAX and XML. Developers talk a lot about community when the term Web 2.0 comes up. And whether you think it’s hype or not, the idea … Continue reading

Posted in General | Tagged , , , | Leave a comment

Don’t use addslashes for database escapes

From jansch.nl: This is not the best way to escape data. The most important reason is security. addslashes can lure you into a false sense of security. As Chris Shiflett points out, there are situations that addslashes doesn’t escape. Use … Continue reading

Posted in General | Tagged , , | Leave a comment

PHP 5: MySQL Singleton Example

What is a Singleton? In software engineering, the singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the … Continue reading

Posted in General | Tagged , , , | Leave a comment

File Downloads With Zend Framework

I have been handling file uploads in most of my web applications. Sometimes, I store them in databases and sometimes I feel like storing them in directories. This post will not deal with uploading files, but rather downloading them. Basically, … Continue reading

Posted in General | Tagged , , | Leave a comment

10 projects every php developer should use

This news has circulating around the PHP Community for a few days already – posting it here for record purposes. As a php web developer, you should know that php is probably the language that has the biggest code repository. … Continue reading

Posted in General | Tagged , , , | 4 Comments

Simple CAPTCHA Tutorial with Zend Framework

UPDATE 2008-10-24 This guy has an updated post for Zend_Captcha. Mine is old an out-dated. Here is how to create a simple Captcha image with the Zend Framework. I have created this controller named: ImagegeneratorController. The job of this controller … Continue reading

Posted in General | Tagged , , | 43 Comments

Get Difference Between 2 Dates Using PHP

Here is how to get the difference between two dates in PHP. … public static function toTimestamp($date){ $arrayDate=self::toArray($date); return mktime($arrayDate[’hour’],$arrayDate[’minute’],$arrayDate[’second’],$arrayDate[’month’],$arrayDate[’day’],$arrayDate[’year’]); }   public static function dateDiff($date1,$date2,$unit=’HOUR’){ $date1=self::toTimestamp($date1); $date2=self::toTimestamp($date2);   $secs=$date1-$date2;   switch(strtoupper($unit)){ case ‘WEEK’:return $secs/60/60/24/7; break; case ‘DAY’:return $secs/60/60/24; break; … Continue reading

Posted in General | Tagged , | Leave a comment