<? php echo ("<pre>"); ..... echo("</pre>"); ?> 是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4756842/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does <? php echo ("<pre>"); ..... echo("</pre>"); ?> mean?
提问by woel
The question is the tag <pre> </pre>
问题是标签 <pre> </pre>
I've seen one script I am working on, uses it:
我看过我正在编写的一个脚本,使用它:
echo ("<pre>");
echo ("<pre>");
.... ....
…………
echo ("</pre>");
echo ("</pre>");
What exactly does it do ?
它到底有什么作用?
Is it an Html tag or a PHP ?
它是一个 Html 标签还是一个 PHP ?
I've searched on Google but nothing much comes out of it. When do we usually use that HTML tag?...or PHP tag?
我在谷歌上搜索过,但没有什么结果。我们通常什么时候使用那个 HTML 标签?...或 PHP 标签?
回答by Merijn
The <prev>
tag doesn't exist, but it's probably the <pre>
HTML tag to put around debug output, to improve readability. It's not a secret PHP hack. :)
该<prev>
标签不存在,但它可能是<pre>
用于调试输出的HTML 标签,以提高可读性。这不是一个秘密的 PHP 黑客。:)
回答by Mark
I think you're talking about <pre></pre>
. element is displayed in a fixed-width font, and it preserves both spaces and line breaks.
我想你在谈论<pre></pre>
. 元素以固定宽度字体显示,并保留空格和换行符。
try printing an array with a **<pre>**
and whitout **<pre>**
尝试用 a**<pre>**
和 whitout打印一个数组 **<pre>**
$arr = array(1, 2, 3); echo '<pre>'; print_r($arr); echo '</pre>'; print_r($arr);
$arr = array(1, 2, 3); echo '<pre>'; print_r($arr); echo '</pre>'; print_r($arr);
回答by Jan Sverre
The PHP function echo() prints out its input to the web server response.
PHP 函数 echo() 将其输入输出到 Web 服务器响应。
echo("Hello World!");
prints out Hello World! to the web server response.
打印出Hello World!到 Web 服务器响应。
echo("<prev>");
prints out the tag to the web server response.
将标签打印到 Web 服务器响应中。
echo do not require valid HTML tags. You can use PHP to print XML, images, excel, HTML and so on.
echo 不需要有效的 HTML 标签。您可以使用 PHP 打印 XML、图像、excel、HTML 等。
<prev> is not a HTML tag. Is is a valid XML tag, but since I don't know what page you are working in, i cannot tell you what it is. Maybe it is the root tag of a XML page, or a miswritten <pre> tag.
<prev> 不是 HTML 标签。Is 是一个有效的 XML 标记,但由于我不知道您在哪个页面上工作,因此我无法告诉您它是什么。也许它是 XML 页面的根标签,或者是一个误写的 <pre> 标签。
回答by Nanne
echo ("");
is a php code, and <prev>
tries to be HTML, but isn't.
echo ("");
是一个 php 代码,并<prev>
试图成为 HTML,但不是。
As @pekka said, its probably supposed to be <pre>
正如@pekka 所说,它可能应该是 <pre>
回答by VGE
It is nor php nor html it sounds like specific xml tag.
它既不是 php 也不是 html 听起来像是特定的 xml 标签。
回答by tijntest
try this:
尝试这个:
$names = array('Jesse', 'joey', 'jelnny', 'justine');
$names = new ArrayObject($names);
echo '<pre>';
print_r($names);
vs this:
与这个:
$names = array('Jesse', 'joey', 'jelnny', 'justine');
$names = new ArrayObject($names);
//echo '<pre>';
print_r($names);
and it shows what the PRE does very neatly
它非常巧妙地展示了 PRE 所做的事情
回答by Nikos
"<pre>"
is an HTML tag. If you insert this line of code in your program
"<pre>"
是一个 HTML 标签。如果在程序中插入这行代码
echo "<pre>";
echo "<pre>";
then you will enable the viewing of multiple spaces and line endings. Without this, all \n
, \r
and other end line characters wouldn't have any effect in the browser and wherever you had more than 1 space in the code, the output would be shortened to only 1 space. That's the default HTML. In that case only with <br>
you would be able to break the line and go to the next one.
然后您将启用查看多个空格和行尾。如果没有这个,所有\n
,\r
和其他结束行字符在浏览器中都不会产生任何影响,只要代码中有超过 1 个空格,输出就会缩短到只有 1 个空格。这是默认的 HTML。在那种情况下,只有和<br>
你在一起才能打破线并进入下一个。
For example,
例如,
the code below would be displayed on multiple lines, due to \n
line ending specifier.
由于\n
行尾说明符,下面的代码将显示在多行上。
<?php
echo "<pre>";
printf("<span style='color:#%X%X%X'>Hello</span>\n", 65, 127, 245);
printf("Goodbye");
?>
However the following code, would be displayed in one line only (line endings are disregarded).
但是,以下代码将仅显示在一行中(忽略行尾)。
<?php
printf("<span style='color:#%X%X%X'>Hello</span>\n", 65, 127, 245);
printf("Goodbye");
?>
回答by systemovich
The <prev>
-tag might be an XML-tag.
该<prev>
-tag可能是一个XML标签。
回答by Design by Adrian
if you put text within an HTML tag, all spaces and line breaks will be preserved.
如果将文本放入 HTML 标记中,则将保留所有空格和换行符。
Otherwise, the default behaviour is to remove multiple spaces and keep only one space, and ignore line breaks (unless you use the
tag).
否则,默认行为是删除多个空格并仅保留一个空格,并忽略换行符(除非您使用
标记)。
I'd like to say it's from the time before CSS - not necessarily used to make text more legible, only more formatted.
我想说它是在 CSS 出现之前的时代 - 不一定用于使文本更清晰,只是更格式化。
回答by Gajendra K S
here whatever we write in between the pre tags it will be interpreted same as html pre tag
这里无论我们在 pre 标签之间写什么,它都会被解释为与 html pre 标签相同
ex:
前任:
<?php
echo '<pre>';
echo '
code here
will be displayed
as it
is
namaste
';
echo "this line get printed in new line";
echo "</pre>";
echo "Now pre ended:";
echo "this line gets joined to above line";
?>
and content b/w 's font also changes.
和 content b/w 的字体也会改变。