?
Solved

php strings

Posted on 2003-02-26
4
Medium Priority
?
222 Views
Last Modified: 2008-03-04
Because I have worked with C++ a few years ago I know that C++ and PHP have some string endings like \n and \r. Now I need them for a little project, but I don't know what they all do. Could anyone help me with that?
0
Comment
Question by:bapperlo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:Oliver_Dornauf
ID: 8024143
this are escape characers. \n is for carrige return \r is a tabulator
0
 
LVL 2

Accepted Solution

by:
linxit earned 150 total points
ID: 8024909
Actually, \n is linefeed, \r is carriage return. On UNIX-like systems (e.g. Linux) only \n is needed for a CRLF, whereas on DOS/Windows both \r\n are required.

\t is a tab character.

In "double-quoted strings", you also need to escape certain other characters in order to print them:

\\ for a backslash
\$ for a dollar sign
\" for a double-quote

In 'single-quoted strings' you only need to escape a
single-quote itself - everything else is treated as a
normal character.

See http://www.php.net/manual/en/language.types.string.php for the relevant PHP manual page.
0
 
LVL 15

Expert Comment

by:VGR
ID: 8024943
yes to linxit, except that "[on *nix] only \n [being linefeed] is needed for a CRLF" is a bit misleading as CRLF means CarriageReturn+LineFeed ;-)

the complete truth is that *nix systems are happy with lines ended by line feed (LF) whilst others (Mac included?) need CRLF
0
 
LVL 2

Expert Comment

by:linxit
ID: 8025198
Yes, I didn't explain it as well as I could have. We could say that a linefeed implies a carriage return on *nix whereas it doesn't on DOS/Win (I don't know how Macs do it).
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question