dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Escape Sequences in Literals

Learn how string and character literals provide an escape mechanism that allows express character codes that would otherwise not be allowed.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


String and character literals provide an escape mechanism that allows express character codes that would otherwise not be allowed in the literal. An escape sequence consists of a backslash character (\) followed by one or more other characters. The same sequences are valid in both character and string literals.

The complete set of escape sequences is as follows:

Escape sequence meaning:

\\ Denotes a backslash (\) character
\' Denotes a single-quote (') character
\" Denotes a double-quote (") character
\n Denotes a line feed (LF) character
\r Denotes a carriage return (CR) character
\t Denotes a horizontal tab (HT) character
\f Denotes a form feed (FF) character
\b Denotes a backspace (BS) character
\<octal> Denotes a character code in the range 0 to 255. 

The <octal> in the above consists of one, two or three octal digits ('0' through '7') which represent a number between 0 and 255 (decimal).

 

Visit the DevX Tip Bank

 





   
Octavia Andreea Anghel is a senior PHP developer currently working as a primary trainer for programming teams that participate at national and international software-development contests. She consults on developing educational projects at a national level. She is a coauthor of the book "XML Technologies--XML in Java" (Albastra, ISBN 978-973-650-210-1), for which she wrote the XML portions. In addition to PHP and XML, she's interested in software architecture, web services, UML, and high-performance unit tests.
Thanks for your registration, follow us on our social networks to keep up-to-date