To retrieve a page that includes query string variables, use http_build_query( ) to create the query string. It accepts an array of key/value pairs and returns a single string with everything properly escaped. You’re still responsible for the ? in the URL that sets off the query string.
<?php $vars = array('page' => 4, 'search' => 'this & that'); $qs = http_build_query($vars); $url = 'http://www.w3mentor.com/search.php?' . $qs; $page = file_get_contents($url); ?>