【问题标题】:getting 500 internal server error? [closed]收到 500 内部服务器错误? [关闭]
【发布时间】:2014-11-29 12:42:23
【问题描述】:

这是造成问题的 php 代码

<?php
$link = $_SERVER['PHP_SELF'];
$link_array = explode('/',$link);
$last_part = end($link_array);
if($last_part == "funnyprank01.php"||$last_part == "funnyprank02.php"||$last_part == "funnyprank03.php"||$last_part == "funnyprank04.php")
{
<meta property="og:image"            content="http://i1.ytimg.com/vi/3uRpVGkVhVI/hqdefault.jpg">
<meta property="og:image:type"       content="image/jpg">
}
else
{
<meta property="og:image"            content="http://www.8mags.com/images/youtubeimage.png">
<meta property="og:image:type"       content="image/png">
}
?>

在添加此代码之前,一切正常。包含此代码的文件名为 header.php

【问题讨论】:

  • 在输出原始内容之前需要关闭 PHP 标签。
  • 所以在 if 部分之后我应该关闭?> 然后对于 else 部分重新开始?
  • 您的编辑看起来正确,如果您收到其他错误,请告知。
  • 不,它现在工作正常。谢谢。
  • 别忘了通过选择一个答案来标记这个已解决:)

标签: php server


【解决方案1】:
<?php
$link = $_SERVER['PHP_SELF'];
$link_array = explode('/',$link);
$last_part = end($link_array);
if($last_part == "funnyprank01.php"||$last_part == "funnyprank02.php"||$last_part ==     "funnyprank03.php"||$last_part == "funnyprank04.php")
{
?>
<meta property="og:image"            content="http://i1.ytimg.com/vi/3uRpVGkVhVI/hqdefault.jpg">
<meta property="og:image:type"       content="image/jpg">
<?php
}
else
{
?>
<meta property="og:image"            content="http://www.8mags.com/images/youtubeimage.png">
<meta property="og:image:type"       content="image/png">
<?php
}
?>

如果仍然返回 500 错误,请参阅我的原始答案

【讨论】:

  • 我是负1,你是负1。没人知道为什么?
  • 我知道为什么,请参阅您问题下的评论。我公然错过了。
  • 我正在编辑代码以显示它应该是什么样子。如果我错了,请纠正我?
【解决方案2】:

别忘了关闭 php 标签。

<?php
$link = $_SERVER['PHP_SELF'];
$link_array = explode('/',$link);
$last_part = end($link_array);
if($last_part == "funnyprank01.php"||$last_part == "funnyprank02.php"||$last_part == "funnyprank03.php"||$last_part == "funnyprank04.php"):?>
<meta property="og:image"            content="http://i1.ytimg.com/vi/3uRpVGkVhVI/hqdefault.jpg">
<meta property="og:image:type"       content="image/jpg">
<?php else:?>
<meta property="og:image"            content="http://www.8mags.com/images/youtubeimage.png">
<meta property="og:image:type"       content="image/png">
<?php endif?>

【讨论】:

    【解决方案3】:

    改成:

    <?php
    $link = $_SERVER['PHP_SELF'];
    $link_array = explode('/',$link);
    $last_part = end($link_array);
    if($last_part == "funnyprank01.php"||$last_part == "funnyprank02.php"||$last_part == "funnyprank03.php"||$last_part == "funnyprank04.php")
    { ?>
    <meta property="og:image"            content="http://i1.ytimg.com/vi/3uRpVGkVhVI/hqdefault.jpg">
    <meta property="og:image:type"       content="image/jpg">
    
    <?php }
    else
    { ?>
    <meta property="og:image"            content="http://www.8mags.com/images/youtubeimage.png">
    <meta property="og:image:type"       content="image/png">
    <?php } ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-17
      • 2020-11-20
      • 2018-11-03
      • 1970-01-01
      相关资源
      最近更新 更多