title: Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION) or const (T_CONST)
body: <p>I keep getting the error </p>
  
  <blockquote>
    <p>Parse error: syntax error, unexpected '?>', expecting function
    (T_FUNCTION) or const (T_CONST)</p>
  </blockquote>
  
  <p>From what I read this usually points to a missing "}", but everything seems to match up no matter how many times I read over it. I also tried removing one of the "}" in case I had one too many, but it came back with the error `</p>
  
  <blockquote>
    <p>Parse error: syntax error, unexpected end of file</p>
  </blockquote>
  
  <p>`.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;?php
  class Post{ 
       private $user_obj;
       private $con;
  
       public function __construct($con, $user){
              $this-&gt;con = $con;
              $this-&gt;user_obj = new User($con, $user);
       }
  
  
       public function submitPost($body, $user_to) {
           $body = strip_tags($body); //removes any HTML tags             
           $body = mysqli_real_escape_string($this-&gt;con, $body); //Allows the use of " ' " so it doesn't think it's a new string. 
           $check_empty = preg_replace('/\s+/', '', $body); //Deletes all spaces
  
           if($check_empty != "") {
  
  
               //Current date and time
               $date_added = date("Y-m-d H:i:s");
               //Get username
               $added_by = $this-&gt;user_obj-&gt;getUsername();
  
               //if user is on their own profile, user_to is 'none'
               if($user_to == $added_by) {
                   $user_to = "none";
               }
  
               //insert post
              $query = mysqli_query($this-&gt;con, "INSERT INTO posts VALUES('', 
              '$body', '$added_by', '$user_to', '$date_added', 'no', 'no', 
              '0')");
  
               $returned_id = mysqli_insert_id($this-&gt;con);
  
               //Insert notification
  
               //Update post count for user
               $num_posts = $this-&gt;user_obj-&gt;getNumPosts();
               $num_posts++;
               $update_query = mysqli_query($this-&gt;con, "UPDATE users SET 
               num_posts='$num_posts' WHERE username='$added_by'");
           }
       }
  ?&gt;
  </code></pre>