Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explain what &quot means

I can't find a clear explanation of what it means when a value/variable is surrounded by '&quot' and why it happens.

For example, I have a simple function which returns an array containing an id.

return [params[:id]]

For some reason, it returns:

["4"]

not:

[4]

which I would have expected.

Can someone explain what '&quot' is and why/how they are inserted?

like image 500
user3711600 Avatar asked Jul 07 '14 02:07

user3711600


1 Answers

Unicode

I believe it's something called unicode - a standardized way of outputting typography & character sets in digital media. Unicode takes many forms, ASCII being one of the most widely used.

The problem you have, as referred to in the comments, is that as you returned the pure param, you're getting back the string representation of its contents. Whilst the actual contents of the variable will be ["4"], HTML will treat it as [&quot4&quot]

If you want to output the returned data, you may want to try the [.raw()][2] method in your view:

<%= raw( [data] ) %>
like image 121
Richard Peck Avatar answered Oct 22 '22 14:10

Richard Peck