20+ PHP web developer tips

This is my personal collection of tips for web developers. This is supposed to grow big! Please be patient and link this only when it’s decent or at least half finished. Read more…

Pading numbers with zeros in PHP and MySQL

PHP:

$Num = 99
echo str_pad($Num, 3, "0", STR_PAD_LEFT);
// outputs: 099

MySQL:

SELECT LPAD(Num,3,"000") FROM table

Keep studying Bruno, keep studying

Keep studying Bruno, keep studying.

Keep studying Bruno, keep studying.

Test your PHP in: http://www.zend.com/store/education/certification/self-test.php

Also:

Hello!

I just finished the PHP Syntax Exam at http://www.blueshoes.org/en/developer/syntax_exam/ in 3045 seconds and had 7 errors in 69 questions.

Do you think you can beat me? :-)

Greetings

Controlling PHP error output with .htaccess

If you run Apache with PHP, you can control PHP error output in a per-directory basis, without changing settings in php.ini by writting php directives to a .htaccess file.

Create a file named .htaccess in the webserver directory you want to configure and put those values in it:

php_flag display_errors On
php_value error_reporting E_ALL

For more explanation on error_reporting behaviour and parameters read about it in PHP manual.