var_dump
閲覧数:1001
投稿日: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" }