Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

PHP: New line constant

Posted on 2009-05-12
2
Medium Priority
?
1,269 Views
Last Modified: 2012-05-06
Is there a constant or something that I can use for a OS compatible new line?

Something that will automatically use \n for Linux and \r for Windows?
0
Comment
Question by:hankknight
[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 Comments
 
LVL 7

Expert Comment

by:Jonah11
ID: 24369038
I don't know if there is a built-in constant, but one approach would be to make a custom function.  psuedo code:



function mycr() {
 
  $os = php_uname('s');//get the os
  //process the returned value to something standard, ie, change anything containing "Win" to "WINDOWS" or some such
 
  //now branch off that
  if ($os == "Linux")
     return "\n"
  else if ($os == "Windows")
     return "\r"
}

Open in new window

0
 
LVL 12

Accepted Solution

by:
alien109 earned 2000 total points
ID: 24369090
PHP_EOL
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

647 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