• 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 strcmp() – Binary safe string comparison
  2. PHP function stripslashes() – Un-quotes a quoted string
  3. PHP connection_status function – Returns connection status bitfield
  4. PHP function strlen() – Get string length
  5. PHP Function str_split() – Convert a string to an array
  6. htaccess Cheatsheet
  7. PHP Function str_word_count() – Return information about words used in a string
  8. PHP function convert_cyr_string() – Convert from one Cyrillic character set to another
  9. PHP function chop() – Alias of rtrim()
  10. PHP function str_repeat() – Repeat a string

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright