Failed to open stream
<p>I'm trying to use file_get_contents but it tells me failed to open stream.</p>

<p>My code:</p>

<pre><code>$user="first_last@ourwiki.com";
$user_id=str_replace(array('@', '#'), array('%40', '%23'), $user);
print $user_id;

$url=('http://admin:password@172.16.214.133/@api/users/=$user_id/properties');
$xmlString=file_get_contents($url);
</code></pre>

<p>This is what I get when I try to run it:</p>

<blockquote>
  <p>Warning:
  file_get_contents(http://...@172.16.214.133/@api/deki/users/=$user_id/properties):
  failed to open stream: HTTP request
  failed! HTTP/1.1 500 Internal Server
  Error</p>
</blockquote>

<p>However, if I manually type in the $user_id <strong>first_last%40ourwiki.com</strong> then it works! What am I doing wrong? Shouldn't I be able to just use the variable name?</p>

<p>Remaining code:</p>

<pre><code>$delete = "http://admin:password@172.16.214.133/@api/users/=$user_id/properties/%s";
$xml = new SimpleXMLElement($xmlString);

function curl_fetch($url,$username,$password,$method='DELETE')
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch,CURLOPT_USERPWD,"$username:$password");
    return  curl_exec($ch);
}

foreach($xml-&gt;property as $property) {
  $name = $property['name'];
  $name2 =str_replace(array('@', '#'), array('%40', '%23'), $name);
  print $name2;
  curl_fetch(sprintf($delete, $name2),'admin','password');
}
</code></pre>
