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
Solved

PHP: New line constant

Posted on 2009-05-12
2
1,237 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
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

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

Suggested Solutions

Title # Comments Views Activity
Google Maps API and PHP 25 48
Currency in SQL? 2 29
jQuery Toggle & Anchor Links 5 42
How to make a good PHP + MySQL + JS pagination system? 3 30
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

766 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