简体   繁体   中英

how do i use php as a placeholder in html in laravel?

Im trying to set the placeholder of a field to the users name and email that i get using php. i can print the email and name in the web page by doing:

{{$user->email}}
{{$user->name}}

but i want to add it as a placeholder but when i add the above it prints out the whole line instead of the value:

So i am trying to add it in the following line of code in stead of 'Name' it should be the value of {{$user->name}}:

{{Form::text('name', '', ['class' => 'form-control','placeholder' => 'Name', 'style' => 'margin-bottom: 5px;', 'readonly'])}}

how would i add it in place of 'Name'?

//you can do it as following

<input type="text" name="name" placeholder="{{$user->name}}" class="form-control" style="margin-bottom: 5px;" readonly>

//or you can achieve it by using core php tags

<input type="text" name="name" placeholder="<?php echo $user->name; ?>" class="form-control" style="margin-bottom: 5px;" readonly>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM