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

What to do if line breaks are not displayed in php

藏色散人
Release: 2023-03-13 10:48:01
Original
2866 people have browsed it

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 "测试下换行符有没有用";
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template