
ショコラ
PHPで変数の中身を返すには?
var_export関数(再帰NG)、print_r関数(再帰OK)を使う。

もっさん先輩
$str = var_export({変数},true)
Laravel で var_export の結果をログファイルに出力するなら↓下のように書きます。
\Log::debug(var_export({変数},true));
「var_export does not handle circular references」のエラーが表示されたら、var_export の代わりに print_r を使う。
$str = print_r({変数},true)
Laravel で print_rの結果をログファイルに出力するなら↓下のように書きます。
\Log::debug(print_r({変数},true));
昔 、わざわざ下のようにやってしまっていたかも・・・。
<?php
ob_start();
var_dump({変数});
ob_get_clean();
以上