得到500内部服务器错误?

时间:2014-11-29 12:42:24

标签: php server

这是创建问题的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

3 个答案:

答案 0 :(得分: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
}
?>

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

答案 1 :(得分:1)

不要忘记关闭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?>

答案 2 :(得分: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 } ?>