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 "
".
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 :
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!