<?php
$uri = $_SERVER['REQUEST_URI'];
$button1URI = '/button1uri'; //uri страницы первой кнопки
$button2URI = '/button2uri'; /uri страницы второй кнопки
?>
..... .....
<button id="button1" class="<?php if($uri === $button1URI) {echo 'active'}?>">button1</button>
<button id="button2" class="<?php if($uri === $button2URI) {echo 'active'}?>">button2</button>