English 中文(简体)
产出“<> 括号内的特征
原标题:Output "<"/">" Character in HTML

I m trying to display "<"/">" as String in HTML not as a tag.

I have a database that contains user s Fullname and Email and when I want display them both I have a format like this:

Christian Eric Paran <>>

但我只表示:

<代码>。 Eric Paran

是否可采用一种方式,从购买力平价中显示这种数据。

最佳回答
问题回答

问题为:<代码><和>>为超文本标记。 因此,电子邮件地址最终被捆绑为超文本标签,最终被多数甚至所有浏览者隐藏起来。

使用<代码>&lt;至显示< in RUS, and &gt; for >

If the data will be dynamic, use htmlentities or htmlspecialchars to do the above encoding for you prior to printing it.

您需要将htmlspecialchars改为适当的超文本实体,例如&lt;

由于你正在处理电子邮件地址,你确信,你需要一定的灵活性,才能处理你如何展示其结果,而不只是躲藏各党派。

I would recommend http://php.net/mailparse_rfc822_parse_addresses

   $email = mailparse_rfc822_parse_addresses("Christian Eric Paran <[email protected]>") ;
   echo $email[0][ display ] ; // Christian Eric Paran
   echo $email[0][ address ] ; // [email protected]

如果你没有邮局,你可以使用。

$email = parse_addresses ( "Christian Eric Paran <[email protected]>" );
echo $email [ display ]; // Christian Eric Paran
echo $email [ address ]; // [email protected]

职能

function parse_addresses($address) {
    $info = array ();
    preg_match_all (  /s*"?([^><,"]+)"?s*((?:<[^><,]+>)?)s*/ , $address, $matches );
    $info [ display ] = $matches [1] [0];
    $info [ address ] = str_replace ( array (
            "<",
            ">" 
    ), "", $matches [2] [0] );

    return $info;
}




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签