Backport for php5.3