我最近用LAMP安装了一个Fedora 20 VPS。我的PHP运行正常,您可以从下面的输出中看到:http://talkoot.co.in/info.php
我的问题是,当我访问下面的页面时,php脚本会打印出来,而不是执行。如果一个"Views Source",那么整个代码都是可见的。http://talkoot.co.in/WebBackend/admin/login.php
有人能帮我吗。以下是login.php的代码:
<?php
include 'init.php';
if(isset($_SESSION['admin'])){
header('Location: index.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>Login - CPanel</title>
<link type="text/css" rel="stylesheet" href="libs/css/materialize.min.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="libs/css/style.css" media="screen,projection"/>
</head>
<body>
<div class="container">
<div class="card publish-form-container">
<?php
if(isset($_POST['username'],$_POST['password'])){
$__USERS->adminLogin($_POST);
}
?>
<form class="col s12" method="POST" action="" >
<div class="input-field">
<input id="username-field" type="text" name="username">
<label for="username-field">Username...</label>
</div>
<div class="input-field">
<input id="password-field" type="password" name="password">
<label for="password-field">Password...</label>
</div>
<div>
<button class="btn waves-effect waves-light pull-right" type="submit">Login
<i class="mdi-content-send right"></i>
</button>
</div>
</form>
</div><!-- Post Card //-->
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="libs/js/materialize.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.materialboxed').materialbox();
});
</script>
</body>
</html>
您的服务器未启用Short Open Tag有两种情况
- 从php.ini
short_open_tag = On
或使用htaccess启用它 - 使用
<?php
而不是<?
p.S:我分享了一个链接,可以解释为什么我提供了两个选项
正如我在phpinfo页面中看到的:
short_open_tag Off Off
这意味着短开放标签现在被允许
因此,您放入短标记<? ?>
中的任何内容都不会被解析为PHP。您宁愿将它放在标准标记<?php ?>
块中。