Daily Technology News, Tips, and Reviews | Subscribe to Jason Slater Technology BlogTechnology Feed | Join Jason Slater on TwitterTwitter | Thursday 2nd September 2010

PHP: Add Slashes to text

By Jason Slater
  • DiggThis
  • Share

It is sometimes necessary to maintain the special characters in text, such as the apostrophe, speech marks, null character and backslash as these can be mis-interpreted by systems such as SQL if not modified appropriately. The generally accepted method of achieving this is to use the addslashes command which prefixes the special characters with the backslash symbol.

 

$inputData = "The is a quote '";
$Description = addslashes($inputData);
echo "Revised Text: " . $Description;

 

A useful introduction to SEO can be found at:

SEO: A simple introduction (part 1).

This article is bought to you by: SL8R Codezone.

Technorati Tags: sl8r,code zone,

Related