string addslashes function - returns a string with backslashes before quoted characters

string addslashes function - returns a string with backslashes before quoted characters

string-addslashes-function-in-php.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>string addslashes function - returns a string with backslashes before quoted characters</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="Author" content="Md Iqbal Hosan">
  <meta name="title" content="string addslashes function - returns a string with backslashes before quoted characters">
  <meta name="keywords" content="php, example, code, array, function, addslashes, string">
  <meta name="description" content="string addslashes function - returns a string with backslashes before quoted characters">
  <style>
   h2, h4{background:#eee; color:#000076;}
   h2{ padding:3px; margin:3px; font-size:22px;}
   h4{ padding:2px; margin:2px; font-size:18px;}
   p{padding:2px; margin:2px; color:orange;}
   body{ background:#FFFFFc;}
  </style>
 </head>
 <body>
  <h2>string addslashes function - returns a string with backslashes before quoted characters</h2>
  <pre>
   <?php
    /*
     -------------------------------------
     let us make quoted string for test
     -------------------------------------
    */
    $myQuotedString = "my boss's favorite color is orange";
    echo "<h4>Output of myQuotedString in the browser</h4>";
    print "<p>$"."myQuotedString = {$myQuotedString}</p>";
    print "<p>string length : ".strlen($myQuotedString)."</p>";
    /*
     ----------------------------------------------------------------------------------------
     i want to add a slashe before the quoted characeter by using addslashes string function
     ----------------------------------------------------------------------------------------
    */
    $mySlashedString = addslashes($myQuotedString);
    echo "<h4>Output of mySlashedString by using string addslashes function</h4>";
    print "<p>$"."mySlashedString = {$mySlashedString}</p>";
    print "<p>string length : ".strlen($mySlashedString)."</p>";
    /*
     --------------------------------------------------------------------------
     professionally this function is used rapidly to insert data into database
     and it is a part of SQL injection protection
     --------------------------------------------------------------------------
    */
   ?>
  </pre>
 </body>
</html>

string addslashes function - returns a string with backslashes before quoted characters - output in the browser

No comments:

Post a Comment

leave your comments here..