這個問題是關係到downcasting in php5多麼昂貴的這個PHP向下轉換解決方法
這個PHP是如何昂貴的向下轉換解決方法嗎?
這個PHP下變頻解決方法太昂貴了嗎?
我回應microtimes和它似乎需要0.001。我想知道這可能是一個大問題。
public static function to($obj) {
return unserialize(preg_replace(
'/^O:\d+:\"(\w+)/',
'O:' . strlen('this_class_name') . ':"' . 'this_class_name',
serialize($obj)));
}
http://php.net/manual/en/language.types.type-juggling.php建議的解決方案的評論是類似的。
當你想測試成本時,你不應該運行一次。在循環中運行數千次,並打印出所需的時間。然後找出你的應用程序中正常的通話量,看看它是否很貴:) – 2009-11-13 13:44:42