Search code examples
phphtmlsyntax-errorparse-error

Parse error: syntax error unexpected end of file in php


Here is my code, I check all closing & open brace,I also not use its short form of php anywhere & i don't miss ';',
I don't know why Its shows parse error:

<html>
 <head>

  <script type="text/javascript" src="<?php echo base_url('assests/js/jquery.min.js') ?>"></script>
  <link rel="stylesheet" type="text/css" href="<?php echo base_url('assests/css/bootstrap.min.css') ?>">
  <script type="text/javascript" src="<?php echo base_url('assests/js/bootstrap.min.js') ?>"></script>
 </head>
  <body>
   <div class="container">
    <table class="hover hover-table">
       <tr>
        <th>No</th>
        <th>Code</th>
        <th>Name</th>
        <th>Address</th>
       </tr>
       <?php if(count($all_user>0))
         { $i=0;
       foreach ($all_user as $user) 
          {

           $i++;
       ?>
     <tr>
      <td><?php echo $i ?></td>
      <td><?php echo $user->code ?></td>
      <td><?php echo $user->name?></td>
      <td><?php echo $user->address ?></td>
    </tr>
         }
      }
  </table>
 </div>

  </body>
  </html>

Solution

  • You're missing the closing php tags before curly braces <?php }}. Becasue of that you're getting Line : 36 -- syntax error, unexpected end of file

    Try this way,

    <html>
     <head>
      <script type="text/javascript" src="<?php echo base_url('assests/js/jquery.min.js') ?>"></script>
      <link rel="stylesheet" type="text/css" href="<?php echo base_url('assests/css/bootstrap.min.css') ?>">
      <script type="text/javascript" src="<?php echo base_url('assests/js/bootstrap.min.js') ?>"></script>
     </head>
      <body>
       <div class="container">
        <table class="hover hover-table">
           <tr>
            <th>No</th>
            <th>Code</th>
            <th>Name</th>
            <th>Address</th>
           </tr>
           <?php if(count($all_user>0))
             { $i=0;
           foreach ($all_user as $user) 
              {
    
               $i++;
           ?>
         <tr>
          <td><?php echo $i ?></td>
          <td><?php echo $user->code ?></td>
          <td><?php echo $user->name?></td>
          <td><?php echo $user->address ?></td>
        </tr>
           <?php
             }
           }
          ?>
      </table>
     </div>
    
      </body>
      </html>