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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Apr 25 14:01:31 2024 UTC