Sunday, October 24, 2010

Solution - "Fatal error: Maximum execution time of 30 seconds exceeded"

There are two methods to solve this problem (Fatal error: Maximum execution time of 30 seconds exceeded).

Method 1:
Step 1 : Open php.ini
Step 2 : Modify the value of "max_execution_time" to a greater value say 600
Step 3: Restart Server
Done.

Method 2 (Recommended):
Add "set_limit_time(600)" in your code, where the input parameter is the max execution time, and 0 means unlimited.

Explanation:
You should be aware of this error message, because it should not take more than 30s to complete a script normally. Sometime, it may because of coding mistakes like (infinity loop in your code).

However, you may really need to execute heavy code in many cases, then I would recommend you to use the method 2 to solve this problem.

Sunday, October 10, 2010

PHP Filter - email validation

For PHP5, you can validate email format as below:

$email = 'testemail@xxx.com';  
  
if( filter_var($email, FILTER_VALIDATE_EMAIL) )  
 echo 'Valid email format!';  
else  
 echo 'Invalid email format!'; 

For PHP version less than 5.0, you have to use regular expression to validate email format.

$email = 'testemail@xxx.com';  
  
if( eregi('^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$', $email) ) 
 echo 'Valid email format!';  
else  
 echo 'Invalid email format!'; 


For reference:

You can found out more build-in validates at php.net each as URL, IP validation which are very useful.
http://php.net/manual/en/filter.filters.validate.php

Friday, October 8, 2010

An IDE to recommend - NetBeans

A workman must first sharpen his tools if he is to do his work well. --- A famous word from China.



A good IDE can really boost up your speed on developing.
I tried notepad++ and eclipse before, finally I think NetBeans is the best.

For the php version,
it supports some frameworks like Zend Framework, symfony, smarty.
Let's download and try it!

NetBeans website

Thursday, October 7, 2010