【发布时间】:2019-12-09 05:16:06
【问题描述】:
每当我想查看个人资料时,它都会向我显示一个致命错误,并显示消息
致命错误异常 (E_UNKNOWN) 无法使用 [] 阅读
为什么会这样
@if($user->is_employer() || $user->is_agent())
<div class="profile-company-logo mb-3">
<img src="{{ $user->logo_url[] }}" class="img-fluid" style="max-width: 100px;" />
</div>
@endif
<table class="table table-bordered table-striped mb-4">
<tr>
<th>@lang('app.name')</th>
<td>{{ $user->name }}</td>
</tr>
<tr>
<th>@lang('app.email')</th>
<td>{{ $user->email }}</td>
</tr>
<tr>
<th>@lang('app.gender')</th>
<td>{{ ucfirst($user->gender) }}</td>
</tr>
<tr>
<th>@lang('app.phone')</th>
<td>{{ $user->phone }}</td>
</tr>
<tr>
<th>@lang('app.address')</th>
<td>{{ $user->address }}</td>
</tr>
<tr>
<th>@lang('app.country')</th>
<td>
@if($user->country)
{{ $user->country->name }}
@endif
</td>
</tr>
<tr>
<th>@lang('app.created_at')</th>
<td>{{ $user->signed_up_datetime() }}</td>
</tr>
<tr>
<th>@lang('app.status')</th>
<td>{{ $user->status_context() }}</td>
</tr>
</table>
@if($user->is_employer() || $user->is_agent())
<h3 class="mb-4">About Company</h3>
<table class="table table-bordered table-striped">
<tr>
<th>@lang('app.state')</th>
<td>{{ $user->state_name }}</td>
</tr>
<tr>
<th>@lang('app.city')</th>
<td>{{ $user->city }}</td>
</tr>
<tr>
<th>@lang('app.website')</th>
<td>{{ $user->website }}</td>
</tr>
<tr>
<th>@lang('app.company')</th>
<td>{{ $user->company }}</td>
</tr>
<tr>
<th>@lang('app.company_size')</th>
<td>{{company_size($user->company_size)}}</td>
</tr>
<tr>
<th>@lang('app.about_company')</th>
<td>{{ $user->about_company }}</td>
</tr>
<tr>
<th>@lang('app.premium_jobs_balance')</th>
<td>{{ $user->premium_jobs_balance }}</td>
</tr>
</table>
@endif
@if( ! empty($is_user_id_view))
<a href="{{route('users_edit', $user->id )}}">
<i class="la la-pencil-square-o"></i> @lang('app.edit') </a>
@else
<a href="{{ route('profile_edit') }}"><i class="la la-pencil-square-o"></i> @lang('app.edit') </a>
@endif
单击编辑按钮后,我想查看个人资料并进行编辑。
【问题讨论】:
-
logo_url[]- 有错字吗?? -
你为什么在里面使用
[]? -
好的,它对用户有用,但是,仍然显示“htmlspecialchars() 期望参数 1 是字符串,数组给定”这个给雇主。
-
htmlspecialchars的用法在哪里?该消息应该告诉您您需要知道的一切,expects parameter 1 to be string, array given。你有一个数组,而不是一个字符串。该函数适用于字符串。 -
htmlspecialchars()每次调用{{ $... }}时都会运行;它是blade模板引擎的一部分。本质上,{{ }}中的内容是array而不是string,因此您需要循环该变量才能使用它。喜欢{{ $user->logo_url[] }}?
标签: php database laravel codeigniter web