Laravel only accepts the first character in a string
I am using Laravel 4.2 and am trying to pull a row from a database column named $ meta_title and store that row as a meta tag in a view. It should work like this:
$meta_title = 'Star Wars is Better than Star Trek';
$meta_title
retrieved from the database in the controller and sent to the view via an array
<meta property="og:title" content= {{ $meta_title }} {{ '>' }}
<meta property="og:title" content="Star Wars is Better than Star Trek">
but instead it does this:
<meta property="og:title" content="Star" wars="" is="" better="" than="" star="" trek="">
How can I fix the code so that the meta tag looks like this:
<meta property="og:title" content="Star Wars is Better than Star Trek">
after fetching a row from the database?
+3
source to share
2 answers
You need to put {{ $meta_title }}
insidedouble quote
<meta property="og:title" content="{{ $meta_title }}">
From your code after displaying it in html it will look like this
<meta property="og:title" content= Star Wars is Better than Star Trek >
This is why you got a strange result.
+5
source to share