You can send the current text of the button to the server when clicking the button and compare it with the new random text, if they are not equal, echo it to the page, if they are, continue searching for a non-equal rand text.
Also you can do it with sessions. Put current text in a session var, and create another one in a submission, and compare it to the previously created session var, and echo to the page.
<?php
session_start();
if (isset($_POST)) // check button submission - do it with any way you like
{
while(1)
{
$new_rand = rand();
if($new_rand != $_SESSION['currText'])
{
$curr_text = $new_rand;
$_SESSION['currText'] = $curr_text;
echo "<button>$curr_text</button>";
break;
}
}
}
else // and here is the first page request, when no button is clicked
{
$new_rand = rand();
$_SESSION['curr_text'] = $new_rand;
echo "<button>$new_rand</button>";
}
?>
With this you're going to get completely different texts at each time of pressing the button ;)
In this code and the scenarios above, I talked about random numbers, because PHP rand() function returnes numbers. If you want texts, you can put all the texts you want to show in your page, in an array, and get random one using rand(0, $max_index_of_the_array) - show the text in the array where the text's index came from the rand(0, $max_index_of_the_array).