Pagination for search results from a custom query

the problem was that the get_query_var(‘paged’)or ‘page’ couldn’t read the value .. I don’t know why? .. but it always returns 0; and the check sets $paged to 1 each time … so I got around it, and got the page number from the URL >>> It worked for me on localhost, but I’ve no clue if it works on a host… for your info: I work on WordPress 4.8.1, and use PHP server WAMP 3.0.6 X64 >>> replace

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

with

$p = explode("https://wordpress.stackexchange.com/", $_SERVER['REQUEST_URI']);
$pag = (int)($p[4]*1);
if ($pag == 0 || $pag== null){$paged =1;} else {$paged=$pag;}

tech