简体   繁体   中英

Reading text file truncates line output in PHP

Reading text file truncates line output in PHP:

Text-file:

NEXT_GEN_TO="Project Bribara<project-automation@bribara.com>"

Code:

$lines = file('Text-file');
foreach ($lines as $line) {
   echo "$line</br>";
}

Expected:

NEXT_GEN_TO="Project Bribara<project-automation@bribara.com>"

Actual:

NEXT_GEN_TO="Project Bribara"

How can I print expected result after reading the lines from file?

The <project-automation@bribara.com> is treated as an html tag by your browser. If you check out the outputted html source code for the page using "View Source" in your browser, it's all going to be there.

Use one of the php functions to turn html into non-html text such as htmlentities() on the text before output.

http://php.net/manual/en/function.htmlentities.php

尝试给出这样的输出...

echo htmlentities($line) . "</br>";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM