Catchable fatal error: Object of class DateTime could not be converted to string

エラーメッセージFatal error

エラー発生

 状態:-  閲覧数:3,134  投稿日:2016-04-21  更新日:2016-04-21  
Catchable fatal error: Object of class DateTime could not be converted to string in /★★.php on line ☆☆


エラー原因


DateTimeオブジェクトをそのまま出力しようとしたから


エラー対応


フォーマット後出力

遭遇例

 閲覧数:649 投稿日:2016-04-21 更新日:2016-04-21 

エラーメッセージ


Catchable fatal error: Object of class DateTime could not be converted to string in /demo/session/set_save_handler/new-pdo/5.4-less/2/customize/2/DbSessionHandler.php on line 166


エラー原因


DateTimeオブジェクトをそのまま出力しようとしたから
$date = new DateTime();
echo $date;



エラー対応


フォーマット後出力
$date = new DateTime();
echo $date->format('Y-m-d H:i:s');




Fatal error: require_once(): Failed opening required 'PEAR.php'

Fatal error: Uncaught Error: Call to a member function modify() on string

コメント投稿(ログインが必要)



週間人気ページランキング / 11-15 → 11-21
順位 ページタイトル抜粋 アクセス数
1 ブラウザを閉じたらセッションデータはどうなるの? | セッション 5
2 Parse error: syntax error, unexpected 'public' (T_PUBLIC) | Parse error(エラーメッセージ) 4
3 Catchable fatal error: Object of class DateTime could not be converted to string | Fatal error(エラーメッセージ) 3
3 セッション管理が必要な理由は、HTTPプロトコルには状態を保持する機能がないため | セッション 3
3 Generator クラス(定義済みのインターフェイスとクラス) カテゴリー 3
4 オブジェクト関係マッピング | データベース関連 2
4 浮動小数点数型(float double) | 型 2
4 ( ! ) Fatal error: Uncaught PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column | Fatal error(エラーメッセージ) 2
4 Warning(エラーメッセージ) カテゴリー 2
4 Warning: strlen() expects parameter 1 to be string, array given in ○○.php on line △△ | Warning(エラーメッセージ) 2
4 Fatal error: Uncaught RuntimeException: SplFileObject::__construct(): failed to open stream: Permission denied in | Fatal error(エラーメッセージ) 2
4 Cookie | クッキー 2
4 $this | クラスとオブジェクト 2
4 PHPで定数を定義する方法は2種類ある / 配列定数の定義 2
4 Fatal error: Uncaught Error: Call to a member function modify() on string | Fatal error(エラーメッセージ) 2
4 その他のサービス カテゴリー 2
4 Parse error: syntax error, unexpected T_INCLUDE, expecting T_FUNCTION | Parse error(エラーメッセージ) 2
4 サニタイズ | セキュリティ 2
4 Fatal error: Call to a member function **() on a non-object in ○○ on line △△ | Fatal error(エラーメッセージ) 2
4 ( ! ) Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'カラム名' cannot be null | Fatal error(エラーメッセージ) 2
2025/11/22 1:01 更新