この内容は古いバージョンです。最新バージョンを表示するには、戻るボタンを押してください。
バージョン:2
ページ更新者:T
更新日時:2026-05-15 03:52:15

タイトル: Object of class stdClass could not be converted to string
SEOタイトル: 【PHPエラー】Object of class stdClass could not be converted to string

この記事の要点
  • PHP の Object of class stdClass could not be converted to string
  • 原因: stdClass オブジェクトを直接文字列演算 / 出力している
  • 対処: 中身を var_dump($obj) で確認 → 該当プロパティ $obj->name を使う
  • JSON 文字列化なら json_encode($obj)

 

エラー内容

Object of class stdClass could not be converted to string

 

発生条件/原因/対処法

stdClass を String に変換しようとすると発生するエラー。

stdClassの中身を確認するには以下の様に var_export を使用すると良い。

var_export($object, true)