title: Logout Button with PHP Classes
body: <p>Right now I'm using jquery to run a php script which isn't working, i know that php is a server side script and you can't run the script from jquery, in that case what is the best way to call a php function within a class from the browser?</p>
  
  <p>This is the class where the logout function is defined  </p>
  
  <pre><code>class Profile
  {
     private function logout()
     {
         $_SESSION = array();
         session_destroy();
     }
  </code></pre>
  
  <p>This is the php page where i want to call the function upon click of the logout button</p>
  
  <pre><code>&lt;?php
  
  include_once('profileclass.php');
  $user = new Profile($name, $id);
  
  ?&gt;
  
  &lt;html&gt;
  &lt;head&gt; &lt;/head&gt;
  &lt;body&gt;
       &lt;input type='button' value='logout' id='logout'&gt;
  
  &lt;script&gt;
      $(function() {
        $('#logout').click(function() {
            &lt;?php $user-&gt;logout(); ?&gt;
        }
        });
      });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>