English 中文(简体)
没收 体能
原标题:Confusing Php function result with nl2br

I m simply experimenting with PHP to prepare me for some upcoming projects and I ve encountered a string which won t have <br /> inserted into it even though it is a multi-line string.

该守则是简明的购买力平价(I ve 载于简单的html标签)。

$ping = passthru( ping www.google.com );
$ping = htmlspecialchars_decode($ping);
$ping = strip_tags($ping);
$ping = nl2br($ping);
echo $ping;

结果是多线铺设,但无任何<条码>和>;br /> 标签,但页数显示,由于双向线铺设,因此该带的条形形形形形色,但<条码>nl2br(>>没有做任何事情。

Page source (which has mysteriously added extra whitespace lines when I pasted it in here)

<html>

    <head>

        <title>Derp</title>



    </head>

    <body><p>



Pinging www.l.google.com [209.85.227.147] with 32 bytes of data:

Reply from 209.85.227.147: bytes=32 time=44ms TTL=48

Reply from 209.85.227.147: bytes=32 time=28ms TTL=48

Reply from 209.85.227.147: bytes=32 time=40ms TTL=48

Reply from 209.85.227.147: bytes=32 time=29ms TTL=48



Ping statistics for 209.85.227.147:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 28ms, Maximum = 44ms, Average = 35ms

</p>

    </body>

</html>

网页上的实际插图:

Pinging www.l.google.com [209.85.227.147] with 32 bytes of data: Reply from 209.85.227.147: bytes=32 time=30ms TTL=48 Reply from 209.85.227.147: bytes=32 time=29ms TTL=48 Reply from 209.85.227.147: bytes=32 time=28ms TTL=48 Reply from 209.85.227.147: bytes=32 time=31ms TTL=48 Ping statistics for 209.85.227.147: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 28ms, Maximum = 31ms, Average = 29ms

在广泛征求所有我的意见之后,可以发现的是那些不使用<代码>nl2br()的人。

我在这里失踪了吗?

最佳回答
<?php 
$ping = `ping www.google.com`;
$ping = nl2br($ping);
echo $ping;
?>

<br />
Pinging www.l.google.com [209.85.147.104] with 32 bytes of data:<br />
<br />
Reply from 209.85.147.104: bytes=32 time=24ms TTL=53<br />
Reply from 209.85.147.104: bytes=32 time=23ms TTL=53<br />
Reply from 209.85.147.104: bytes=32 time=23ms TTL=53<br />
Reply from 209.85.147.104: bytes=32 time=25ms TTL=53<br />
<br />
Ping statistics for 209.85.147.104:<br />
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),<br />

Approximate round trip times in milli-seconds:<br />
    Minimum = 23ms, Maximum = 25ms, Average = 23ms<br />
问题回答

页: 1 它执行<代码>$cmd,但直接向浏览器发送<编码>stdout——你将not结果重新作为指示。 相反,它退回了所谓的<代码>$cmd的返回代码。

如果你想要捕获产出,exec ,并通过$output>。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...