Tag Archives: PHP

Javascript Date.format prototype method.

The following code add’s a format function to the Date objects prototype. It simulates the PHP date.format() function. Date.prototype.format = function(format) { var returnStr = ”; var replace = Date.replaceChars; for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (i – 1 >= 0 && format.charAt(i – 1) == [...]

Posted in JavaScript | Also tagged | Leave a comment

Configure xdebug for PHP

The xdebug extension can be found pre-compiled for windows, linux and OS X systems. http://code.activestate.com/komodo/remotedebugging/ Edit your PHP.ini file to enable the xdebug extension. Under windows: [xdebug] zend_extension=C:\software\php-5.3.2\ext\php_xdebug.dll

Posted in PHP | Also tagged , | Leave a comment

Convert PHP unix timestamp to a MySQL date format

In PHP: $mysqldate = date( ‘Y-m-d H:i:s’, $unixdate ); $unixdate = strtotime( $mysqldate ); In the MySQL query: $query = "UPDATE table SET datetimefield = FROM_UNIXTIME($phpdate) WHERE…"; $query = "SELECT UNIX_TIMESTAMP(datetimefield) FROM table WHERE…";

Posted in PHP | Also tagged | Leave a comment

Disable PHP in a directory

To prevent PHP scripts from executing in a directory add this code to an .htaccess file <Directory "/path/to/my/sfProject/web/uploads"> php_flag engine off </Directory>

Posted in PHP | Also tagged , | Leave a comment

PHP email validation

Link to the google code project for email address validation. http://code.google.com/p/php-email-address-validation/ Checkout the code with subversion svn checkout http://php-email-address-validation.googlecode.com/svn/trunk/ php-email-address-validation-read-only

Posted in PHP | Also tagged , | Leave a comment