开发者

cUrl not working in PHP

I am trying to have a php script that displays a url with user da开发者_如何学编程ta in it. The script is shown as follows.

<?php 
$url = "localhost/" + $_GET['type'] + "/" + str_replace(' ','%20',$_GET['message']) + "/";
print $url;
// create curl resource 
$ch = curl_init(); 
// set url 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_PORT, 6677); 
//return the transfer as a string 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
// $output contains the output string 
$output = curl_exec($ch); 
// close curl resource to free up sylstem resources 
curl_close($ch);

if ($output) { 
print $output;
}
else
{
print 'FAILED';
}
?>

This is part of a game that I am trying to make where the people talk using A.L.I.C.E, written in AIML (Artificial Intellagence Markup Language). I am using PyAIML. It needs to connect to a Python server on a different port.

The says when a request is received and it does not say it is getting a request at the when I load the page. I used tamper data to remove ALL request headers and it still worked with Firefox.


The problem is with your first line. You're using the numeric addition operator + when you want to use the string concatenation operator instead .

Before:

$url = "localhost/" + $_GET['type'] + "/" + str_replace(' ','%20',$_GET['message']) + "/";

After:

$url = "http://localhost/" . $_GET['type'] . "/" . str_replace(' ','%20',$_GET['message']) . "/";

Also, note it couldn't hurt to explicitly declare the protocol portion of the URL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜