久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

列出 Laravel 視圖中的所有注冊(cè)變量

List all registered variables inside a Laravel view(列出 Laravel 視圖中的所有注冊(cè)變量)
本文介紹了列出 Laravel 視圖中的所有注冊(cè)變量的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在使用 Laravel 5.我想知道哪些是傳遞給視圖本身內(nèi)部視圖的所有變量.

I am using Laravel 5. I would like to know which are all variables passed to a view inside the view itself.

由于所有變量都在視圖范圍內(nèi),我認(rèn)為我可以使用通用的 PHP 函數(shù):get_defined_vars(); http://php.net/manual/en/function.get-defined-vars.php

Since all variables are in the view scope I thought I could use the generic PHP function: get_defined_vars(); http://php.net/manual/en/function.get-defined-vars.php

像這樣:

  // resources/view/home.blade.php
  <html>
  <body>
       <?php print_r(get_defined_vars()); ?>
  </body>
  </html>

但是我想知道是否有更好的方法(例如View::getData())

But I would like to know if there is a better way (something like View::getData())

注意: get_defined_vars() 不起作用,因?yàn)樗祷亓藬?shù)百個(gè)無用的變量(Laravel 組件)

Note: get_defined_vars() deosn't work becausee it returns hundreds of useless variables (Laravel components)

這是一個(gè)使用 print_r(get_defined_vars()) 的片段(部分)(我認(rèn)為它進(jìn)入無限遞歸循環(huán)):

This is a snippet (partial) using print_r(get_defined_vars()) (i think it goes in infinite recursion loop):

      Array
(
    [__path] => C:
etlaravelstorageframeworkviews/8e030a77b0bdbacc2c4182fc04420d1d
    [__data] => Array
        (
            [__env] => IlluminateViewFactory Object
                (
                    [engines:protected] => IlluminateViewEnginesEngineResolver Object
                        (
                            [resolvers:protected] => Array
                                (
                                    [php] => Closure Object
                                        (
                                            [this] => IlluminateViewViewServiceProvider Object
                                                (
                                                    [app:protected] => IlluminateFoundationApplication Object
                                                        (
                                                            [basePath:protected] => C:
etlaravel
                                                            [hasBeenBootstrapped:protected] => 1
                                                            [booted:protected] => 1
                                                            [bootingCallbacks:protected] => Array
                                                                (
                                                                    [0] => Closure Object
                                                                        (
                                                                            [static] => Array
                                                                                (
                                                                                    [instance] => IlluminateBusBusServiceProvider Object
                                                                                        (
                                                                                            [defer:protected] => 1
                                                                                            [app:protected] => IlluminateFoundationApplication Object
 *RECURSION*
                                                                                        )

                                                                                )

                                                                            [this] => IlluminateFoundationApplication Object
 *RECURSION*
                                                                        )

                                                                    [1] => Closure Object
                                                                        (
                                                                            [static] => Array
                                                                                (
                                                                                    [instance] => IlluminateTranslationTranslationServiceProvider Object
                                                                                        (
                                                                                            [defer:protected] => 1
                                                                                            [app:protected] => IlluminateFoundationApplication Object
 *RECURSION*
                                                                                        )

                                                                                )

                                                                            [this] => IlluminateFoundationApplication Object
 *RECURSION*
                                                                        )

                                                                )

                                                            [bootedCallbacks:protected] => Array
                                                                (
                                                                )

                                                            [terminatingCallbacks:protected] => Array
                                                                (
                                                                )

                                                            [serviceProviders:protected] => Array
                                                                (
                                                                    [0] => IlluminateEventsEventServiceProvider Object
                                                                        (
                                                                            [app:protected] => IlluminateFoundationApplication Object
 *RECURSION*
                                                                            [defer:protected] => 
                                                                        )

推薦答案

使用 dd 助手:

{{ dd(get_defined_vars()) }}

閱讀更多:https://laravel.com/docs/5.4/helpers#method-dd

更新(thx,@JoeCoder):您可以通過執(zhí)行以下操作進(jìn)一步減少無用"變量:

Update (thx, @JoeCoder): you can further cutdown on the "useless" variables by doing:

{{ dd(get_defined_vars()['__data']) }}

這篇關(guān)于列出 Laravel 視圖中的所有注冊(cè)變量的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

add new element in laravel collection object(在 Laravel 集合對(duì)象中添加新元素)
Creating an edit modal in Laravel 5(在 Laravel 5 中創(chuàng)建編輯模式)
Laravel 5.5 API resources for collections (standalone data)(用于集合的 Laravel 5.5 API 資源(獨(dú)立數(shù)據(jù)))
What is the best practice to create a custom helper function in php Laravel 5?(在 php Laravel 5 中創(chuàng)建自定義輔助函數(shù)的最佳實(shí)踐是什么?)
No #39;Access-Control-Allow-Origin#39; header - Laravel(沒有“Access-Control-Allow-Origin標(biāo)頭 - Laravel)
Laravel Passport Route redirects to login page(Laravel Passport Route 重定向到登錄頁(yè)面)
主站蜘蛛池模板: 人人九九精| 男女羞羞网站 | 日中文字幕在线 | 免费黄色av网站 | 国产成人福利视频在线观看 | 国产精品精品视频一区二区三区 | 欧美日韩中文字幕在线 | 久久精品一区二区 | 精品欧美一区二区在线观看视频 | 久草热视频 | 欧美午夜影院 | 亚洲一区二区精品视频 | 你懂的在线视频播放 | 亚洲欧美综合精品久久成人 | 狠狠干影院 | 国产高清免费 | 精产国产伦理一二三区 | 国产精品色婷婷久久58 | 日韩激情一区 | 91麻豆精品国产91久久久更新资源速度超快 | 免费黄色片视频 | 亚洲国产成人av好男人在线观看 | 欧美一区二区三区在线观看 | 天天激情综合 | av中文字幕在线观看 | 一级片av | 日韩国产中文字幕 | 色婷婷一区二区三区四区 | 日韩成人一区 | 日韩免费一二三区 | 九九热在线免费视频 | 天天插天天干 | 免费一级黄| 韩国毛片一区二区三区 | 中文字幕在线三区 | 国产美女一区二区 | 国产精品一区二区在线 | 91成人| 久久国产精品一区二区三区 | 亚洲综合大片69999 | 国产成人免费在线观看 |