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

デバッグ

var_dump

 閲覧数:632  投稿日: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内容をテキストファイル出力



週間人気ページランキング / 3-19 → 3-25
順位 ページタイトル抜粋 アクセス数
1 後ろから3文字削除 / 「18:00:00」→「18:00」 | 文字列(テキスト処理) 26
2 指定文字列より前を取得 | 文字列(テキスト処理) 16
3 URLから、トップページ(index.html)判定 | ルーティング 12
3 「input type="datetime-local"」で受け取った文字列をハイフンへ変更 | 日付および時刻関連 12
4 null代入とunset()の違い | 変数 10
5 現在WebページのURLパスを第2階層まで取得 | パス 9
6 PHPコード 8
7 foreachの中でswitch文 | 配列(型) 6
7 平均値、分散、標準偏差を求める | 統計 6
8 配列の内容(ひらがな)を、読み(あ行~わ行)で分け、新たな配列へ格納 | 配列(型) 3
8 配列内容を、foreachでテーブル表示 | テーブル 3
8 マテリアルカラーをランダムに3色取得 / 重複なし | 色 3
8 Smartyのテンプレートにincludeしたファイルを表示 | Smarty(テンプレートエンジン) 3
9 ビルトインクラス(クラス) カテゴリー 2
9 「最後に位置している指定文字列」より後の文字列を取得 | 文字列(テキスト処理) 2
9 ファイル名を取得し、.拡張子部分を削除し、タイトルに表示 | ファイルシステム 2
9 配列の空要素を削除 / array_diff()で空配列と比較し配列の差分を返す | 配列(型) 2
9 ネットワーク 関数 カテゴリー 2
9 Noticeエラー回避 / PHP7以上で使用可能なnull合体演算子(??)を使用 | 演算子 2
9 平均値、分散、標準偏差、学力偏差値を求める | 統計 2
2023/3/26 1:01 更新