How to display pagination in moderation and not all the pages say?

Now brought the pagination but in such a way that they hatched every one that is 1 2 3 4 5 6 7 8
And I would like normal type only 5 pages and there is a trace of the previous page
July 4th 19 at 23:02
1 answer
July 4th 19 at 23:04
<?php
$curent = 0;
$last_page = $curent + 5;
while ($curent++<$last_page) echo $curent;
?>

Find more questions by tags PHP