链接html中的注销按钮以注销php

Does anyone know why my logout button isn't working. I have created a button in my html which looks like this

    <button  href="logout.php">Logout </button>

And then I have a php file called logout.php which looks like this.

 <?php
session_start();

if(session_destroy()) {
  header("Location: index.html");
}
?>

I don't know how to connect the two, if anyone could help me that would be great. Thanks

this will work you can call the php file using the bellow code

as far as my knowledge you can call an href directly from button either you should use anchor tag or form to submit to particular link. Here is the thread related to your query

<a href="your link..." class="btn btn-success">Logout</a>

It can not work on old php version. What is your PHP version? Or you may try session_unset() instead of session_destroy().

There is anchor tag to redirect a page . But you want to use button then it can achieve by using javascript

  <button onclick="window.location.href='logout.php'">Logout</button>  

Change

 <button  href="logout.php">Logout </button>

To

 <button><a href="logout.php">Logout</a></button>