像PHP_EOL一样常量用于制表php

时间:2016-09-19 10:13:16

标签: php tabs eol

请帮忙, 我怎样才能找到像PHP_EOL这样的常量来制表 我的代码编写了文件,其中包含大量生成的表格和新行 新行写得正确,但我有很多" \ t \ t" 见例子:

common.app \t/loader \t/growl \t\t/error \t/form

3 个答案:

答案 0 :(得分:4)

PHP_EOL是来自Core PHP的常量。您可以简单地定义自己的常量并使用它们。例如:

<?php

    defined("TAB1") or define("TAB1", "\t");
    defined("TAB2") or define("TAB2", "\t\t");
    defined("TAB3") or define("TAB3", "\t\t\t");
    defined("TAB4") or define("TAB4", "\t\t\t\t");
    defined("TAB5") or define("TAB5", "\t\t\t\t\t");


    $string = "common.app"     . TAB1 . "/loader" . TAB1 . "/growl" . 
               TAB2 . "/error" . TAB1 . "/form";

答案 1 :(得分:4)

好的,我找到解决方案

chr(9)将制表写入输出文件

谢谢!

答案 2 :(得分:-3)

我用css解决了

<style>
.MyCSS{
    border:1px solid #FFF; 
    width:10em; 
    float:left; 
    font-weight:bold;
    }
</style>
<?php 
// here the selection query
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { ?>
<div>
<div class="MyCSS">
<?php stripslashes($row['Country']);?>
</div>
<?php echo stripslashes($row['CountryDescription'])."<br>";?> 
</div>
<div style="clear:both;"></div>
<?php } ?>
相关问题