syntax error, unexpected end of file

I'm practicing Codeigniter PHP Framework, also I'm very new to it. I have created View (login.php) in view folder of Framework. My issue is that I'm getting the following error:

Parse error: syntax error, unexpected end of file

Please check the code with what is the syntax error into it.

<h2>Login</h2>
<?php if($error==1){ ?>
<p>Your username / password did not match.</p>
<? } ?>
<form action="<?=base_url?>users/login" method="post">
    <p>Username: <input type="text" name="username" /></p>
    <p>Password: <input type="password" name="password" /></p>
    <p><input type="submit" value="Login" /></p>
</form>

There are a few issues with your code.

Firstly, you are using short tag syntax when it hasn't been enabled on your system.

Consult the manual:

  • http://php.net/manual/en/ini.core.php#ini.short-open-tag
  • Then your form's action="<?=base_url?>users/login"

    or as stated in comments action="<?php echo base_url ?>/users/login" with the extra slash.

    You missed the () in order to declare it as a function.

  • base_url() is a function so you need to add the () to it, which is why you're getting the following error:
  • A PHP Error was encountered Severity: Notice Message: Use of undefined constant base_url - assumed 'base_url'

    as stated in comments.

    Additional documentation:

  • https://www.codeigniter.com/user_guide/helpers/url_helper.html
  • 链接地址: http://www.djcxy.com/p/69800.html

    上一篇: PHP登录并获取用户信息

    下一篇: 语法错误,意外的文件结束