1

I have set up a small web server using my Raspberry Pi SOC, and I am currently writing some PHP code to be displayed in the browser using the Nano text editor.

I wish to have my code separated on new lines, but the newline characters I have tried (PHP_EOL and "\n") within the Nano text editor don't seem to be recognized when opening the binary.php file from the browser. Below I have screenshots of the PHP source code and the current display from the browser.

Any thoughts?

PHP source code screenshotDisplay of binary.php in browser

user3783243
  • 5,368
  • 5
  • 22
  • 41
  • 1
    This has nothing to do with nano. The newline character has no meaning in HTML. – tkausl Feb 14 '19 at 15:36
  • 2
    Browsers do not process new lines. You'll need to use `
    `. New lines are for non-browser output, such as text files and the console.
    – aynber Feb 14 '19 at 15:36
  • if you don't need html, than you can change the content-type to text like `header("Content-type: text/plain);`. otherwise replace `\n` with `
    `
    – spinsch Feb 14 '19 at 15:44
  • I'm able to add HTML code within the binary.php file? I added the line break and now my file won't open in browser.. – Connor Burleson Feb 14 '19 at 15:44
  • Show your code with the line break. Remember that it's text and not a PHP global, so it needs to be within the quotes. – aynber Feb 14 '19 at 15:47
  • I added quotes around the line break and it worked. I appreciate the help everyone! Learning more and more each day.. – Connor Burleson Feb 14 '19 at 15:53
  • did you try printf "\n"; – Yassine CHABLI Feb 14 '19 at 16:22
  • Possible duplicate of [PHP won't output new line](https://stackoverflow.com/questions/16991841/php-wont-output-new-line) – Nico Haase Feb 14 '19 at 16:30
  • Possible duplicate of [PHP - how to create a newline character?](https://stackoverflow.com/questions/4238433/php-how-to-create-a-newline-character) – xerx593 Feb 14 '19 at 17:13

1 Answers1

1

You need to use the

<br/> 

character instead

Russ J
  • 828
  • 5
  • 12
  • 24