Replace php5.2 incompatible funtion