// Value to be passed to the next page
$search = 'hello world!';

// Encode the value for use in a query string
$encodedSearch = urlencode($search);

// Append the encoded value to the URL
$url = 'https://example.com/search.php?q=' . $encodedSearch;

echo $url;
// Output: 'https://example.com/search.php?q=hello+world%21'
$keyword = 'iPhone & Galaxy/Note=100% #1';
$encoded = rawurlencode($keyword);

echo 'https://example.com/search?query=' . $encoded;
// Output: 'https://example.com/search?query=iPhone%20%26%20Galaxy%2FNote%3D100%25%20%231'
$data = array(
    'name' => 'John Doe',
    'age' => 30,
    'city' => 'New York'
);

$queryString = http_build_query($data);
echo $queryString;

// Output: 'name=John+Doe&age=30&city=New+York'