Laravel 5.3 - htmlspecialchars() expects parameter 1 to be string : <p>I am new to laravel and I am enjoying it. While working on a social media project I got this error: <code>htmlspecialchars() expects parameter 1 to be string, object given (View: C:\wamp64\www\histoirevraie\resources\views\user\profile.blade.php)</code></p>

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

<p>this is what my <code>profile.blade.php</code> is made of:</p>

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

<p>All the information about the user are given by a controller:</p>

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

<p>Kindly help me solve this problem!</p>
