php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49487 addslashes — Quote string with slashes
Submitted: 2009-09-06 19:44 UTC Modified: 2009-09-07 10:49 UTC
From: shefik at allknightaccess dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.3.0 OS: Mac 10.5.8
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: shefik at allknightaccess dot com
New email:
PHP Version: OS:

 

 [2009-09-06 19:44 UTC] shefik at allknightaccess dot com
Description:
------------
Please add a new parameter for the function addslashes, where it flags 
what type of character to quote string with slashes.

Such as:

SINGLE
DOUBLE
BACKSLASH
NULL
ALL

All would remain the default, as it is right now. Example use with the 
new parameter:

<?php
$str = "He asked, \"Is your name O'reilly?\"";

// Outputs: He asked, "Is your name O\'reilly?"
echo addslashes($str, SINGLE);
?>

<?php
$str = "He asked, \"Is your name O'reilly?\"";

// Outputs: He asked, \"Is your name O'reilly?\"
echo addslashes($str, DOUBLE);
?>


<?php
$str = "He asked, \"Is your name O'reilly?\"";

// Outputs: He asked, \"Is your name O\'reilly?\"
echo addslashes($str, ALL);
?>



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-07 10:49 UTC] scottmac@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

We have this with addcslashes where you can provide a character list to escape.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC