ZARU(ざる)のWeb系ブログですー。プログラミング&デザイン関係のTipsとか色々と。

CakePHPをPHP5.3で使うとエラーになる時の対処法

水曜日, 3月 10th, 2010

PHP5.3だとエラーが色々と…

PHP5.1からPHP5.3へアップデートをすると、CakePHP1.2においてエラーが出てしまったので、その場合の対処法。

Deprecatedエラーが出る

Deprecated: Assigning the return value of new by reference is deprecated in云々なエラー。

  • cake/libs/configure.php (295行目付近)
if (isset($config['debug'])) {
	if ($_this->debug) {
		error_reporting(E_ALL);
		//下記追加
		if (error_reporting() > 6143) {
			error_reporting(E_ALL & ~E_DEPRECATED);
		}
		//ここまで

strtotime()でタイムゾーンのエラーが出る

Warning: strtotime() [http://php.net/function.strtotime]: It is not safe to rely on the system’s timezone settings.というエラー。

  • /etc/php.ini
[Date]
; Defines the default timezone used by the date functions
;date.timezone =
date.timezone =Asia/Tokyo

と、タイムゾーンを設定してやれば大丈夫。