- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is there a PHP function that only adds slashes to double quotes NOT single quotes
The json_encode function can be used to add slashes to double quotes. Also ‘addcslahses’ can also be used to add ‘\’ to specific characters −
<?php $str = addcslashes("Hello there!","t"); echo($str); ?>
This will produce the following output −
The ‘addcslashes’ function is used to return a string with backslashes in front of the specific characters. It is a case sensitive function and should usually not be used with 0 (null), r (carriage return), n (newline), f (form read), t (tab), v (vertical tab) values. This is because values like \0, \r, \n, \t, \f and \v are pre-define escape sequences.
In the above code, the ‘addcslashes’ function is called on the string by specifying that the backslash has to occur before the character ‘t’.
- Single quotes vs. double quotes in C or C++
- Single and Double Quotes in Perl
- Print newline in PHP in single quotes
- What is the difference between single and double quotes in python?
- How to escape single quotes in MySQL?
- Find records with double quotes in a MySQL column?
- How to insert records with double quotes in MySQL?
- CSS quotes Property
- How to print double quotes with the string variable in Python?
- Using MySQL keywords in a query surrounded with single quotes?
- Which MySQL function can be used to append values of a column with single quotes?
- Convert all types of smart quotes with PHP
- MySQL throws an error when the table name “match” is not surrounded by single quotes?
- Triple Quotes in Python