Solved

PHP: New line constant

Posted on 2009-05-12
2
1,245 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
Uploading a CSV Data Import via PHP & MySql 3 53
Showing multiple maps using PHP and Google Maps 12 38
scan php uploads for viruses 5 23
MySQL-Design Help 12 38
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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.

679 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