PHP - Escape Characters

0
12K

Escape Character

To insert characters that are illegal in a string, use an escape character.

An escape character is a backslash \ followed by the character you want to insert.

An example of an illegal character is a double quote inside a string that is surrounded by double quotes:

ExampleGet your own PHP Server

$x = "We are the so-called "Vikings" from the north.";
Try it Yourself »

To fix this problem, use the escape character \":

Example

$x = "We are the so-called \"Vikings\" from the north.";
Try it Yourself »

Escape Characters

Other escape characters used in PHP:

Code Result Try it
\' Single Quote Try it »
\" Double Quote Try it »
\$ PHP variables Try it »
\n New Line Try it »
\r Carriage Return Try it »
\t Tab Try it »
\f Form Feed  
\ooo Octal value Try it »
\xhh Hex value Try it »
Căutare
Categorii
Citeste mai mult
Alte
تطورات التعلم الآلي وتأثيرها على مستقبل العمل
مقدمة: في ظل التطورات السريعة للتكنولوجيا والابتكار، أصبح التعلم الآلي...
By MOHAMED ATTALLAH 2024-05-14 13:56:58 0 7K
Alte
PHP if Operators
Comparison Operators If statements usually contain conditions that compare two values....
By PHP Tutorial 2024-05-17 07:45:46 0 5K
Alte
PHP if...else Statements
PHP - The if...else Statement The if...else statement executes some code if a...
By PHP Tutorial 2024-05-17 07:46:12 0 4K
Alte
PHP if Statements
Conditional statements are used to perform different actions based on different conditions....
By PHP Tutorial 2024-05-17 07:45:23 0 5K
Alte
PHP Sorting Arrays
The elements in an array can be sorted in alphabetical or numerical order, descending or...
By PHP Tutorial 2024-05-17 08:06:46 0 9K
Sociallez https://sociallez.com