2015-11-10 11:04 阅读 65

网页echos php脚本部分

I have recently setup a Fedora 20 VPS with LAMP. My PHP is working properly as you can see from output below:

My problem is when I access page below, the php script is printed out instead of being executed. If one 'Views Source' then the entire code is visible.

Can someone help me out. Here is the code for login.php:

include 'init.php';
    header('Location: index.php');
<!DOCTYPE html>
    <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"/>

<div class="container">
    <div class="card publish-form-container">
        <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 class="input-field">
                <input id="password-field" type="password" name="password">
                <label for="password-field">Password...</label>
                <button class="btn waves-effect waves-light pull-right" type="submit">Login
                    <i class="mdi-content-send right"></i>
    </div><!-- Post Card //-->

<script type="text/javascript" src=""></script>
<script type="text/javascript" src="libs/js/materialize.min.js"></script>
<script type="text/javascript">
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    duanmi1900 duanmi1900 2015-11-10 11:27

    Your server is not enabled for Short Open Tag there are 2 scenarios

    1. enable it from php.ini short_open_tag = On or using htaccess
    2. Use <?php instead of <?

    P.S: i have shared a link which can explain you why i presented 2 options

    点赞 评论 复制链接分享
  • douzhuiqiu4923 douzhuiqiu4923 2015-11-10 11:14

    As I can see in your phpinfo page:

    short_open_tag  Off Off

    that means the short open tag are now allowed

    So, anything you put inside short tags <? ?> won't be parsed as PHP. You'd rather put it inside standard tags <?php ?> block.

    点赞 评论 复制链接分享