尽管它几乎可以肯定地在原生 PHP 中按预期工作,但当应用于从 Laravel 控制器馈送到其视图的字符串时,公认的解决方案似乎什么都不做。例如,要转储一个变量,我发现这样做的唯一有效方法是print_r ( $_ENV , true )
通过一个with
方法提供 eg 返回的值,并将封闭pre
标签放入视图中。
控制器:
$sDebugMessages = '$_ENV = '. print_r ( $_ENV , true ) ;
return view ( 'Info' )->with ( 'sPageTitle' , 'What is My Praesidium Central Hub?' )->with ( 'sDebugMessages' , $sDebugMessages ) ;
看法:
pre>{{ $sDebugMessages }}</pre>
结果(已编辑,原因应该很明显:
$_ENV = Array
(
[APP_ENV] => local
[APP_KEY] => xxxxxxxxxxxxxxx
[APP_DEBUG] => true
[APP_LOG_LEVEL] => debug
[APP_URL] => https://localhost
[DB_CONNECTION] => mysql
[DB_HOST] => localhost:3306
[DB_DATABASE] => xxxxxxxxxxxxxxx
[DB_USERNAME] => xxxxxxxxxxxxxxx
[DB_PASSWORD] => xxxxxxxxxxxxxxx
[BROADCAST_DRIVER] => log
[CACHE_DRIVER] => file
[SESSION_DRIVER] => database
[QUEUE_DRIVER] => sync
[MAIL_DRIVER] => smtp
[MAIL_HOST] => xxxxxxxxxxxxxxx
[MAIL_PORT] => 587
[MAIL_ENCRYPTION] => tls
[MAIL_USERNAME] => xxxxxxxxxxxxxxx
[MAIL_PASSWORD] => xxxxxxxxxxxxxxx
[MAIL_FROM_ADDRESS] => xxxxxxxxxxxxxxx
[MAIL_FROM_NAME] => xxxxxxxxxxxxxxx
[MAIL_MODE] => xxxxxxxxxxxxxxx
[MAIL_MODE_EMAIL] => xxxxxxxxxxxxxxx
)