Solved

PHP: New line constant

Posted on 2009-05-12
2
1,255 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 500 total points
ID: 24369090
PHP_EOL
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

696 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