Php get_meta_标记不';t获取结果(帮助)

Php get_meta_标记不';t获取结果(帮助),php,html,Php,Html,我想通过用户输入youtube url并在结果中获取关键字或标记 但我不知道怎么了 当我点击提交按钮时,什么也没发生 <?php if( isset($_GET['submit']) ){ $yt = htmlentities($_GET['yt']); $tags = get_meta_tags('$yt'); echo $tags['keywords']; // php documentation ?> Html 提前感谢以下是一个工作示例 &

我想通过用户输入youtube url并在结果中获取关键字或标记

但我不知道怎么了

当我点击提交按钮时,什么也没发生

  <?php if( isset($_GET['submit']) ){ $yt = htmlentities($_GET['yt']);
 $tags = get_meta_tags('$yt');   
  echo 
$tags['keywords'];     // php documentation ?>

Html



提前感谢

以下是一个工作示例

<form >
    <input type="text" name="yt" id="yt"  placeholder="https://youtu.be/jhCD4yCcogE" value="https://youtu.be/jhCD4yCcogE" />
    <input type="submit" name="submit"/>
</form>
代码中有3个小错误:

  • 您的提交名称是
    submit
    您正在检查
    submit
  • 您的提交输入位于
  • 您使用的
    $yt
    有点错误。如果要将变量作为参数发送给函数,则无需使用“$yt”将其包装
  • 这是我提交这份表格后得到的信息

    array (size=22)
      'theme-color' => string '#ff0000' (length=7)
      'title' => string 'Google My Business Website Tutorial | How to Create free website of Google my business 2020' (length=91)
      'description' => string 'Learn how to create google my business website in 5 minutes (complete tutorial). In tutorial will know about description, how to google my business edit with...' (length=160)
      'keywords' => string 'Google My Business Website Tutorial google my business website builder tutorial, free website, google my business, How To Create a Free Website For Google My...' (length=160)
      'twitter:card' => string 'player' (length=6)
      'twitter:site' => string '@youtube' (length=8)
      'twitter:url' => string 'https://www.youtube.com/watch?v=jhCD4yCcogE' (length=43)
      'twitter:title' => string 'Google My Business Website Tutorial | How to Create free website of Google my business 2020' (length=91)
      'twitter:description' => string 'Learn how to create google my business website in 5 minutes (complete tutorial). In tutorial will know about description, how to google my business edit with...' (length=160)
      'twitter:image' => string 'https://i.ytimg.com/vi/jhCD4yCcogE/maxresdefault.jpg' (length=52)
      'twitter:app:name:iphone' => string 'YouTube' (length=7)
      'twitter:app:id:iphone' => string '544007664' (length=9)
      'twitter:app:name:ipad' => string 'YouTube' (length=7)
      'twitter:app:id:ipad' => string '544007664' (length=9)
      'twitter:app:url:iphone' => string 'vnd.youtube://www.youtube.com/watch?v=jhCD4yCcogE&amp;feature=applinks' (length=70)
      'twitter:app:url:ipad' => string 'vnd.youtube://www.youtube.com/watch?v=jhCD4yCcogE&amp;feature=applinks' (length=70)
      'twitter:app:name:googleplay' => string 'YouTube' (length=7)
      'twitter:app:id:googleplay' => string 'com.google.android.youtube' (length=26)
      'twitter:app:url:googleplay' => string 'https://www.youtube.com/watch?v=jhCD4yCcogE' (length=43)
      'twitter:player' => string 'https://www.youtube.com/embed/jhCD4yCcogE' (length=41)
      'twitter:player:width' => string '1280' (length=4)
      'twitter:player:height' => string '720' (length=3)
    

    下面是一个工作示例

    <form >
        <input type="text" name="yt" id="yt"  placeholder="https://youtu.be/jhCD4yCcogE" value="https://youtu.be/jhCD4yCcogE" />
        <input type="submit" name="submit"/>
    </form>
    
    代码中有3个小错误:

  • 您的提交名称是
    submit
    您正在检查
    submit
  • 您的提交输入位于
  • 您使用的
    $yt
    有点错误。如果要将变量作为参数发送给函数,则无需使用“$yt”将其包装
  • 这是我提交这份表格后得到的信息

    array (size=22)
      'theme-color' => string '#ff0000' (length=7)
      'title' => string 'Google My Business Website Tutorial | How to Create free website of Google my business 2020' (length=91)
      'description' => string 'Learn how to create google my business website in 5 minutes (complete tutorial). In tutorial will know about description, how to google my business edit with...' (length=160)
      'keywords' => string 'Google My Business Website Tutorial google my business website builder tutorial, free website, google my business, How To Create a Free Website For Google My...' (length=160)
      'twitter:card' => string 'player' (length=6)
      'twitter:site' => string '@youtube' (length=8)
      'twitter:url' => string 'https://www.youtube.com/watch?v=jhCD4yCcogE' (length=43)
      'twitter:title' => string 'Google My Business Website Tutorial | How to Create free website of Google my business 2020' (length=91)
      'twitter:description' => string 'Learn how to create google my business website in 5 minutes (complete tutorial). In tutorial will know about description, how to google my business edit with...' (length=160)
      'twitter:image' => string 'https://i.ytimg.com/vi/jhCD4yCcogE/maxresdefault.jpg' (length=52)
      'twitter:app:name:iphone' => string 'YouTube' (length=7)
      'twitter:app:id:iphone' => string '544007664' (length=9)
      'twitter:app:name:ipad' => string 'YouTube' (length=7)
      'twitter:app:id:ipad' => string '544007664' (length=9)
      'twitter:app:url:iphone' => string 'vnd.youtube://www.youtube.com/watch?v=jhCD4yCcogE&amp;feature=applinks' (length=70)
      'twitter:app:url:ipad' => string 'vnd.youtube://www.youtube.com/watch?v=jhCD4yCcogE&amp;feature=applinks' (length=70)
      'twitter:app:name:googleplay' => string 'YouTube' (length=7)
      'twitter:app:id:googleplay' => string 'com.google.android.youtube' (length=26)
      'twitter:app:url:googleplay' => string 'https://www.youtube.com/watch?v=jhCD4yCcogE' (length=43)
      'twitter:player' => string 'https://www.youtube.com/embed/jhCD4yCcogE' (length=41)
      'twitter:player:width' => string '1280' (length=4)
      'twitter:player:height' => string '720' (length=3)
    

    get_meta_标记('yt')
    更改为
    get_meta_标记($yt)
    (传递变量而不是文本)。。这里也不需要
    htmlentities()
    ,因为您没有将值输出到客户端。对于未来,始终包括对您的问题的完整和详细的解释。仅仅说“它不起作用”并不能真正告诉我们你的问题。@Magnus Eriksson让我更新并得到it@MagnusEriksson更新代码后什么也没发生我的建议中没有把变量放在单引号内。这将传递文本字符串
    $yt
    ,而不是变量的值。您需要传递实际变量:
    get\u meta\u tags($yt)
    。我也不明白你为什么在这里使用
    htmlentities()
    。当您输出值时(如
    echo
    ),它用于将HTML转义到实体中。它在这里毫无用处。将
    get\u meta\u标记('yt')
    更改为
    get\u meta\u标记($yt)
    (传递变量而不是文本)。。这里也不需要
    htmlentities()
    ,因为您没有将值输出到客户端。对于未来,始终包括对您的问题的完整和详细的解释。仅仅说“它不起作用”并不能真正告诉我们你的问题。@Magnus Eriksson让我更新并得到it@MagnusEriksson更新代码后什么也没发生我的建议中没有把变量放在单引号内。这将传递文本字符串
    $yt
    ,而不是变量的值。您需要传递实际变量:
    get\u meta\u tags($yt)
    。我也不明白你为什么在这里使用
    htmlentities()
    。当您输出值时(如
    echo
    ),它用于将HTML转义到实体中。非常感谢您的更正和详细解释。非常感谢您的更正和详细解释。