如何删除带有 php 的特定 html 元标记?

How can I remove a spcific html meta tag with php?

我想要这个:
如果 php 在 html 来源中找到此特定元标记,则从 header 中删除:

<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />

我试过这种方法,但没有用:

if ( $fullmeta == '<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />') {
     $fullmeta="";  
   }

声明完整元的完整代码块:

<? 
 $video_url = get_field('video_urlasd');
if (isset($video_url) && $video_url !== "https://") {
  $meta1='<meta property="og:video:type" content="application/x-shockwave-flash" />';
  $skinURL="https://neocsatblog.info/skinning-sdk/five/newtube/newtube.xml";
  $meta2=' <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file='.urlencode($video_url).'&autostart=true&skinName=newtube&skinURL='.urlencode($skinURL).'" />';
  $fullmeta=$meta1.$meta2;
  echo $fullmeta;
  }else{
      echo chop($fullmeta,"asd");
  }
   if ( $fullmeta == '<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />') {
     echo $fullmeta="";  
   }
  ?>

我不知道为什么,因为在 HTML 来源上我找到了它,看起来和我复制的一样!

您可以为此使用 str_replace。

$fullmeta = '<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />';
$html_without_crap =  str_replace($fullmeta,"",$Where_it_needs_to_look);

PHP 文档:http://php.net/manual/en/function.str-replace.php

替换您的这部分代码

if (isset($video_url) && $video_url !== "https://") {

有了这个

if (!empty($video_url) && $video_url !== "https://") {