I use Php7.0 and Laravel 5.0 and want to initiate a var in javascript on blade page.
But html_entity_decode function can not decode the special chars.
userName = "{{ html_entity_decode($user->name) }}"
console.log(userName);
I would like to see " ' < >
but it gives me " ' < >
While checkin in db I can see correctly.
Any ideas?
I did some quick testing. And the following example works on my side;
<script type="text/javascript">
var userName = {!! json_encode($user->name) !!};
console.log(userName);
</script>
When I check my console, the userName
is displayed properly.