Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when i run this code gives Parse error: syntax error, unexpected end of file

Tags:

php

<?php
    require('config.php');
    if(isset($_POST['submit'])){
    }else{
    $form =<<<EOT
    <form action="reg.php" method="POST">
        First Name: <input type="text" name="name"/><br />
        Last Name: <input type="text" name="lname"/><br />
        Username: <input type="text" name="uname"/><br />
        Email: <input type="text" name="email1"/><br />
        Confirm Email: <input type="text" name="email2"/><br />
        Password: <input type="password" name="pass1"/><br />
        Confirm Password: <input type="password" name="pass2"/><br />
        <input type="submit" value="Register" name="submit"/>
    </form>
    EOT;
    echo $form;
    }
?>
like image 530
astonish Avatar asked Dec 30 '25 13:12

astonish


2 Answers

Your "EOT" can't be indented, it has to be in the beginning of the line (sadly).

like image 50
Pekka Avatar answered Jan 02 '26 01:01

Pekka


You can't have intendation when beginning and ending the definition of EOT ... ...look at code below. It's not nice (it screws up the intendation for the rest of the code), but this is the only way.

<?php
    require('config.php');

    if(isset($_POST['submit'])){

    }else{
$form =<<<EOT
    <form action="reg.php" method="POST">
    First Name: <input type="text" name="name"/><br />
    Last Name: <input type="text" name="lname"/><br />
    Username: <input type="text" name="uname"/><br />
    Email: <input type="text" name="email1"/><br />
    Confirm Email: <input type="text" name="email2"/><br />
    Password: <input type="password" name="pass1"/><br />
    Confirm Password: <input type="password" name="pass2"/><br />
    <input type="submit" value="Register" name="submit"/>
    </form>
EOT;
    }

    echo $form;

?>
like image 20
bestprogrammerintheworld Avatar answered Jan 02 '26 03:01

bestprogrammerintheworld