我遇到一个PHP页面返回服务器错误500的问题。这种情况只发生在单个页面中。我和主持人谈过了,他们告诉我我的代码有问题。
这是显示错误的文件的内容
<?php
define('APP_URL', 'http://mysit.com/');
define('APP_ID', 'xxxxx');
define('APP_SECRET', 'xxxxx');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>test</title>
<meta property="og:title" content="Which of your friends are secretly smoking?" />
<meta property="og:url" content="<?php echo APP_URL . 'result.php?id=<?php echo trim(htmlentities($_GET['id']))'; ?>"/>
<meta property="og:description" content="test" />
<meta property="og:image" content="<?php echo APP_URL . 'converted/<?php echo $_GET['id']'; ?>.jpg" />
<meta property="fb:app_id" content="<?php echo APP_ID; ?>" />
<meta name="medium" content="image" />
</head>
<body>
<a href="./">test</a>
</body>
</html>
这:
<?php echo APP_URL . 'result.php?id=<?php echo trim(htmlentities($_GET['id']))'; ?>"/>
应该是:
<?= APP_URL.'result.php?id='.htmlentities(trim($_GET['id'])) ?>
还需要对包含嵌入式<?的另一行进行相同类型的更新;?php标签。