var_dump内容をテキストファイル出力

デバッグ

var_dump

 閲覧数:1441  投稿日:2019-02-21  更新日:2019-02-25  

var_dump内容をテキストファイル出力


コード

//Xdebugインストールしている場合
ini_set('xdebug.var_display_max_children', -1);
ini_set('xdebug.var_display_max_data', -1);
ini_set('xdebug.var_display_max_depth', -1);

ob_start();
var_dump($target);
$result =ob_get_contents();
ob_end_clean();

//案1.fopen使用
$fp = fopen('./'.date('Ymd').'dump.txt', 'a+' );
fputs($fp, $result);
fclose( $fp );

//案2.file_put_contents使用
$file = date('Ymd').'_dump2.txt';
file_put_contents($file,$result.PHP_EOL);



結果

/var/www/html/■■/php-demo.w4c.work/demo/settlement/stripe/checkout-beta/2/webhook.php:78:
class stdClass#1 (9) {
  public $id =>
  string(28) "evt_▼▼"
  public $object =>
  string(5) "event"
  public $api_version =>
  string(10) "2019-02-19"
  public $created =>
  int(1550632594)
  public $data =>
  class stdClass#4 (1) {
    public $object =>
    class stdClass#2 (6) {
      public $object =>
      string(13) "checkout_beta"
      public $client_reference_id =>
      NULL
      public $display_items =>
      array(1) {
        ...
      }
      public $line_items =>
      NULL
      public $livemode =>
      bool(false)
      public $payment_intent =>
      string(27) "pi_◇◇"
    }
  }
  public $livemode =>
  bool(false)
  public $pending_webhooks =>
  int(1)
  public $request =>
  class stdClass#5 (2) {
    public $id =>
    NULL
    public $idempotency_key =>
    NULL
  }
  public $type =>
  string(31) "checkout_beta.session_succeeded"
}




タグ


var_dump 



エラーログファイル出力

var_export内容をテキストファイル出力



週間人気ページランキング / 11-6 → 11-12
順位 ページタイトル抜粋 アクセス数
1 PHPコード 31
2 MySQLのdatetime型カラムより取得した「月日文字列」先頭に0があった場合、削除 | 日付および時刻関連 4
3 Noticeエラー回避 / PHP7以上で使用可能なnull合体演算子(??)を使用 | 演算子 3
3 MySQLのdatetime型カラムに格納している値と比較して、24時間以内かどうかを判定 | 日付および時刻関連 3
3 配列の内容(ひらがな)を、読み(あ行~わ行)で分け、新たな配列へ格納 | 配列(型) 3
3 クッキー カテゴリー 3
3 Ctype 文字タイプチェック(バリデーション) カテゴリー 3
3 MySQLi (MySQL) カテゴリー 3
4 realpath(__DIR__) | パス 2
4 Smartyのテンプレートにincludeしたファイルを表示 | Smarty(テンプレートエンジン) 2
4 指定文字が2回目に出現する位置以降の文字列を取得 | 文字列(テキスト処理) 2
4 数字を3桁でカンマ区切りに | 文字列(テキスト処理) 2
4 ファイル名を取得し、.拡張子部分を削除し、タイトルに表示 | ファイルシステム 2
4 defined | タグ毎エントリー一覧 2
4 現在WebページのURLパスを第2階層まで取得 | パス 2
5 「指定文字」から「指定文字」までの文字列を削除 | マルチバイト文字列(テキスト処理) 1
5 文字列の中で変数展開される要件 | 文字列(テキスト処理) 1
5 文字列を「複数の区切り文字」で配列へ変換 / preg_split使用案。採用 | 文字列(テキスト処理) 1
5 対象文字列へ対して、一致したすべての文字列を置換する標準関数 / str_replace | 文字列(テキスト処理) 1
5 「1週間後の年月日時分秒」を表示 … time() | 日付および時刻関連 1
2026/11/13 5:05 更新