• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

PHP function stripcslashes() – Un-quote string quoted with addcslashes()

by admin

stripcslashes() converts C-style escape sequences (\, \a, \b, \f, \n, \r, \t, \v, and \x hh hex and \ ooo octal character escape sequences) to their literal equivalents. Additionally, it strips the backslash from escape sequences that it doesn’t recognize. You can specify ranges of characters by separating them by two periods; for example, to un-escape characters between a and q, use “a..q”. Multiple characters and ranges can be specified in characters. The stripcslashes() function is the inverse of addcslashes().

Syntax:

stripcslashes(string $string): string

To remove backslashes without performing conversions:

stripslashes() 

To add escape sequences to a string:

addslashes() 
addcslashes()

Parameters

Parameter Description
string The string to be unescaped.

Return Values

Returns the unescaped string.

Examples

Example 1:

<?php
var_dump(stripcslashes('I\'d have a coffee.\nNot a problem.') === "I'd have a coffee. Not a problem."); // true
?>

Final Thoughts

The addcslashes function returns the text argument after escaping characters in the style of the C programming language. Briefly, this means special characters are replaced with codes, such as \n replacing a newline character, and other characters outside ASCII 32-126 are replaced with backslash octal codes.

Filed Under: PHP

Some more articles you might also be interested in …

  1. PHP function str_ireplace() – Case-insensitive version of str_replace()
  2. PHP function strlen() – Get string length
  3. PHP cos function – Cosine
  4. PHP base_convert function – Convert a number between arbitrary bases
  5. PHP function acos – Arc cosine
  6. PHP atanh function – Inverse hyperbolic tangent
  7. PHP bindec function – Convert a number between arbitrary bases
  8. “Access denied for user ‘username’@’hostname’ (using password: YES)” – Error while connecting MySQL with PHP
  9. PHP function str_replace() – Replace all occurrences of the search string with the replacement string
  10. PHP Function strncasecmp() – Binary safe case-insensitive string comparison of the first n characters

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright