" is HTML code and "\n" is ASCII code. The browser parses HTML code, not ASCII code, so using "\n" to break lines does not work. The solution is to replace it with "
"."/> " is HTML code and "\n" is ASCII code. The browser parses HTML code, not ASCII code, so using "\n" to break lines does not work. The solution is to replace it with "
".">

Home  >  Article  >  Backend Development  >  What to do if line breaks are not displayed in php

What to do if line breaks are not displayed in php

藏色散人
藏色散人Original
2021-10-18 09:13:492837browse

php line breaks are not displayed because "
" is HTML code, "\n" is ASCII code, and the browser parses HTML code, not ASCII code, so use "\n" "Line break does not work. The solution is to replace it with "
".

What to do if line breaks are not displayed in php

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

#What should I do if line breaks are not displayed in php?

Newline not working?

Code such as:

<?php
  echo "另外一种格式php书写但是不建议使用";
  echo "\n";
  echo "测试下换行符有没有用";
?>

The line break in the above code does not work, just replace it with What to do if line breaks are not displayed in php:

Because

After you use \n, the browser cannot see the line break, but when you view the source file of the page, You can see that line breaks appear where there are \n in the code. This is because \n can be seen in text files, but
displays line breaks in HTML.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What to do if line breaks are not displayed in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn