Oscar Oscar - 4 months ago 10
SQL Question

HTML closing tags are modified after retrieving from database

I use laravel to retrieve some raw html from mysql database.

The problem is that data is modified after I retrieve it.

Data in database:

<p>888</p>


After retrieval:

<p>888<\/p>


Laravel method used for retrieval:

public function index()
{
$posts = Post::All();
echo $posts;
}


Any idea why it is happening and how to solve it ?

Data type for this column in the database is medumtext.

Thanks.

Answer

/ Slash is a special character. In order to fix ur issue use stripslashes()

public function index()
{
    $posts = Post::All();
    echo stripslashes($posts);
}
Comments