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

Laravel 5.3 - htmlspecialchars() 期望參數 1 為字符串

Laravel 5.3 - htmlspecialchars() expects parameter 1 to be string(Laravel 5.3 - htmlspecialchars() 期望參數 1 為字符串)
本文介紹了Laravel 5.3 - htmlspecialchars() 期望參數 1 為字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我是 Laravel 的新手,我很喜歡它.在處理社交媒體項目時,我收到此錯誤:htmlspecialchars() 期望參數 1 為字符串,給定對象(視圖:C:wamp64wwwhistoirevraie esourcesviewsuserprofile.blade.php)

I am new to laravel and I am enjoying it. While working on a social media project I got this error: htmlspecialchars() expects parameter 1 to be string, object given (View: C:wamp64wwwhistoirevraie esourcesviewsuserprofile.blade.php)

我在這個網站上檢查了一些問題,但我沒有找到解決我問題的問題.

I have checked some questions on this site but I have not found a question that solves my problem.

這是我的 profile.blade.php 的組成:

<ul class="profile-rows">
    <li>
        <span class="the-label">Last visit: </span>
        <span class="the-value mark green">{{ CarbonCarbon::createFromFormat('Y-m-d H:i:s', $user->lastVisit)->diffForHumans(CarbonCarbon::now())}}</span>
    </li>
    <li>
        <span class="the-label">Member since: </span>
        <span class="the-value mark light-gray">{{ $user->created_at->format('F Y') }}</span>
    </li>
    <li>
        <span class="the-label">Profile views: </span>
        <span class="the-value mark light-gray">5146</span>
    </li>
    <li>
        <span class="the-label">Living In: </span>
        <span class="the-value">{{ $user->town }}</span>
    </li>
    <li>
        <span class="the-label">Website: </span>
        <span class="the-value"><a href="{{ url($user->website) }}">{{ $user->website }}</a></span>
    </li>
</ul>

有關用戶的所有信息均由控制器提供:

All the information about the user are given by a controller:

public function index($username){
        $user = User::where('username', $username)->first();
        return view('user.profile', compact('user'));
    }

請幫我解決這個問題!

推薦答案

我認為你的 $user->website 是空的/空白的.

I think your $user->website is empty/blank.

如果您查看 url() 輔助方法,如果 $path 為空,Laravel 將返回 UrlGenerator實例.

If you look at the url() helper method, Laravel will return an instance of UrlGenerator if $path is null.

所以在你的情況下,如果 $user->website 是空的,你會得到 UrlGenerator 回來,因此你關于 htmlspecialchars 的錯誤得到一個對象.

So in your case if $user->website is empty, you'd get UrlGenerator back and thus your error about htmlspecialchars getting an object.

一個簡單的解決方案是用檢查包裹你的 html 塊:

One simple solution would be to wrap your html chunk with a check:

@if($user->website)
    <li>
        ...
    </li>
@endif

這篇關于Laravel 5.3 - htmlspecialchars() 期望參數 1 為字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數)
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應內容必須是實現 __toString()、“boolean和“boolean的字符串或對象.移動到 psql 后給出) - IT屋-程
Roles with laravel 5, how to allow only admin access to some root(Laravel 5 的角色,如何只允許管理員訪問某些根)
Laravel Auth - use md5 instead of the integrated Hash::make()(Laravel Auth - 使用 md5 而不是集成的 Hash::make())
主站蜘蛛池模板: 91青青草视频 | 久久婷婷香蕉热狠狠综合 | 午夜小电影| 红桃视频一区二区三区免费 | 亚洲精品在线免费观看视频 | 日韩精品免费看 | 韩日av片 | 精品久久久久香蕉网 | 久久9999久久 | 91久久国产综合久久 | 日本黄色大片免费 | 国产精品一区二区不卡 | 久久不射电影网 | 成年人在线观看 | 一级片av| 亚洲精品黄色 | 国产精品99久久久久久动医院 | 国产超碰人人爽人人做人人爱 | 老妇激情毛片免费 | 久久久精品一区二区三区四季av | 丝袜美腿一区二区三区动态图 | 美美女高清毛片视频免费观看 | 草草精品 | av毛片在线播放 | 久久久久无码国产精品一区 | 精品99爱视频在线观看 | 一区二区三区在线 | 黄色成人亚洲 | 超碰免费在 | 色久伊人 | 国产精品久久一区二区三区 | 国产一区二区三区在线免费观看 | 国产传媒在线播放 | 在线一区 | 久草在线| 华人黄网站大全 | 国产精品二区三区在线观看 | 免费午夜视频在线观看 | 中文字幕一区在线观看视频 | 欧美9999| 成人高清在线视频 |