English 中文(简体)
为什么有 t子在PHP工作?
原标题:Why doesn t strip_tags work in PHP?

我引用以下法典:

<?php echo strip_tags($firstArticle->introtext); ?>

如果第一元为混凝土,

object(stdClass)[422]
  public  link  => string  /maps101/index.php?option=com_content&view=article&id=57:greenlands-newest-iceberg&catid=11:geography-in-the-news  (length=125)
  public  text  => string  GREENLAND S NEWEST ICEBERG  (length=26)
  public  introtext  => string  <p>A giant chunk of ice calved off the Petermann Glacier on

    the northwest side of Greenland this summer. At nearly 100 square miles (260

    sq. km) in size, four times the size of Manhattan, th  (length=206)
  public  date  => 
    object(JDate)[423]
      public  _date  => int 1284130800
      public  _offset  => int 0
      public  _errors  => 
        array
          empty

您可以看到,第1条及第1条及第1条及第2款所指的是:

<p>A giant chunk of ice calved off the Petermann Glacier, on the North 西边,格陵兰岛西北部。 面积近100平方英里(260平方公里),四倍于曼哈顿,th”。

The <p> tag is a problem for me in this application, however strip_tags absolutely refuses to remove it and I can t figure out why. I actually gave up on strip_tags and attempted to do a preg_replace instead with the regex /<(.| )*?>/ :

preg_replace( /<(.|
)*?>/ ,   , $firstArticle->introtext);

但是,这不行不通! 在我产出时,我怎么能够把所有超文本标签(附后)从该指示中删除?

最佳回答

审判:

<?php echo strip_tags(html_entity_decode($firstArticle->introtext)); ?>
问题回答

很奇怪的是,光栅不发挥作用......。

或许你们的“和;p>”是htmlentity-encoded? 比如,“&lt;p&gt;”

这样做将取代所有标签,也取代同系编码标记,但几乎显而易见的是,这种标语只是直系的,这样一来......

preg_replace( /(?:<|&lt;).*?(?:>|&gt;)/ ,   , $firstArticle->introtext);

在我的案件中,我应使用<代码>htmlspecialchars_decode($str);html_entity_decode($first->introtext)。 我似乎没有工作。

有时我必须首先使用<代码>htmlentities。

        $txt = htmlentities($txt, null,  utf-8 );   
        $txt = htmlspecialchars_decode($txt);




相关问题
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 ...

热门标签