Home  >  Article  >  Backend Development  >  txt文件中包含空格、<br/>怎么原封不动的输出到网页中

txt文件中包含空格、<br/>怎么原封不动的输出到网页中

WBOY
WBOYOriginal
2016-06-13 13:31:271127browse

txt文件中包含空格、
如何原封不动的输出到网页中

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><?php //*****<br/>*****
    if($a){
        echo "+";
    }else{
        echo "#";
    }
    //***** *****
?>

比如上面的文本存入一个a.txt文件中,格式和上面一样,那么php读取a.txt文件如何才能按它文件中一模一样的格式输出到网页中

------解决方案--------------------
echo file_get_contents('a.txt');
------解决方案--------------------
<?php <br />  <br>   //*****<br>*****<br>   if($a){<br>       echo "+";<br>   }else{<br>       echo "#";<br>   }<br>   //***** *****<br>?><br><br>

------解决方案--------------------
...

------解决方案--------------------
PHP code

<?php $text = <<<TXT
 //*****<br/>*****
    if($a){
        echo "+";
    }else{
        echo "#";
    }
    //***** *****
TXT;
echo htmlentities($text);

#页面效果
//*****<br>***** if(){ echo "+"; }else{ echo "#"; } //***** *****

#源码
 //*****<br/>*****
    if(){
        echo "+";
    }else{
        echo "#";
    }
    //***** *****
?> <div class="clear">
                 
              
              
        
            </div>
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