Currently seeking new career opportunities in web development, particularly with Laravel, Hire Me

Magic Quotes

David Carr

Tutorials PHP & MySQL

This tutorial will explain what magic quotes are and how to use them. When Magic Quotes are enabled will automatically escape single and double quotation marks.

This helps prevent problems in php/html.

There are two types of Magic Quotes:

magic_quotes_gpc which works for forms, urls and cookies (gpc stands for get, post and cookie).

magic_quotes_runtime which works for data from external files and databases.

If there is an apostrophe like: dave's then the result would be daves to get round this you can use the function stripslashes() This function removes any backslashes found.

//Example:
$text = "this is dave's data";

if magic quotes are activated on the server then the result when printed would be:

this is daves data

To get round this use stripslashes()

$text stripslashes($text);
$text = "this is dave's data";

the result would then be:

this is dave's data

A doubles backslash will be turned into a single backslash using the stripslashes() function 

Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Learn Laravel with Laracasts

Faster Laravel Hosting

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.