I got failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in php

I got failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in php.

<?php $link = file_get_contents("http://www.abcdef.com/wl/api/allresults?state=".$location->state."&page=".$page); $contents = json_decode($link); ?>

I got solution in google, if you are opening a URL with special characters, such as spaces you to encode the urlencode().
I don’t know how to implement this urlencode in this above coding. can u please help me?
how to solve this issue?

My guess would be

$link = file_get_contents("http://www.abcdef.com/wl/api/allresults?state=".urlencode($location->state)."&page=".urlencode($page));

You might not need the second one if your $page parameter is URL-safe.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.