2015-03-31 83 views
0

为什么我得到这个错误:入门未能打开流:HTTP请求与名称失败的错误与symboles

未能打开流:HTTP请求失败! HTTP/1.1 404未找到

代码:

$Name = 'Teàst'; 
$result = file_get_contents('http://example.com/name/' . $Name .); 

但是当我尝试echo $result;我得到的链接,其做工精细。 当我尝试$Name = 'Teast';(没有“à”符号)它的工作正常。 Soo问题是带有符号的名字(éèà...)。 如何解决它?

回答

0

使用用htmlspecialchars方法,

$Name = 'Teàst'; 
    $result = file_get_contents('http://example.com/name/' . htmlspecialchars($Name)); 
+0

但我的结果中包含的名称和当名称更改为'茶st'的结果 – vladeuurs255s 2015-03-31 07:52:44

+0

@ vladeuurs255s检查我的回答 – 2015-03-31 07:53:08

0

使用

htmlspecialchars()

$Name = 'Teàst'; 
$Name =htmlspecialchars($Name); 
$result = file_get_contents('http://example.com/name/' .$Name); 
+0

我不能执行我的代码的其余未能打开流:HTTP请求失败! HTTP/1.1 400错误请求 – vladeuurs255s 2015-03-31 08:24:31

0

此代码的工作对我来说:

<?php 
$Name = 'Teàst'; 
$result = file_get_contents('http://example.com/name/' . $Name); 
echo $result 
?> 

而且此代码的​​工作:

<?php 

$Name = 'Teàst'; 
$Name = htmlspecialchars($Name); 
$result = file_get_contents('http://localhost/temp/' . $Name); 

echo $result 
?> 
+0

@ vladeuurs255s你有一些进步与你的问题? – 2015-05-01 18:52:01

相关问题