Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
by santy143all » Mon Jan 28, 2013 3:05 am
- Code: Select all
<?php
function build_query_string(array $params) {
$query_string = http_build_query($params);
return $query_string;
}
function curl_get($url) {
$client =curl_init($url);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($client);
curl_close($client);
return $response;
}
?>
when i am calling this function it is showing unable tpo call any one please help me with same
waiting for response am newbie to the php.

-
santy143all
- New php-forum User

-
- Posts: 1
- Joined: Mon Jan 28, 2013 3:00 am
by gether » Mon Jan 28, 2013 3:16 am
i am noobie too ... looks complicated
-

gether
- New php-forum User

-
- Posts: 16
- Joined: Tue Dec 25, 2012 7:38 pm
by us2rn4m2 » Mon Jan 28, 2013 6:21 am
Ok, I am sending you an example that I wrote when I started to learn PHP:
- Code: Select all
$url = 'http://www.webservicex.net/length.asmx/ChangeLengthUnit?';
$params = array(
'LengthValue' => '100',
'fromLengthUnit' => 'Kilometers',
'toLengthUnit' => 'Miles');
$request = $url . http_build_query($params);
function curl_get($request) {
$curl_init = curl_init() or die(curl_error());
curl_setopt($curl_init, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl_init, CURLOPT_URL, $request);
$response = curl_exec($curl_init);
curl_close($curl_init);
return $response;
}
$response = curl_get($request);
echo '<pre>';
echo htmlspecialchars($response);
echo '</pre>';
echo '<br />';
echo '100 Kilometers = ' . $response . ' Miles';
/* Result:
<?xml version="1.0" encoding="utf-8"?>
<double xmlns="http://www.webserviceX.NET/">62.137119223733393</double>
100 Kilometers = 62.137119223733393 Miles
*/
-
us2rn4m2
- New php-forum User

-
- Posts: 13
- Joined: Thu Aug 09, 2012 1:28 pm
by gether » Mon Jan 28, 2013 10:03 am
why do you have to put a $sign every where?
url = 'http://www.webservicex.net/length.asmx/ChangeLengthUnit?';
params = array(
'LengthValue' => '100',
'fromLengthUnit' => 'Kilometers',
'toLengthUnit' => 'Miles');
request = url . http_build_query(params);
why not like this ?
-

gether
- New php-forum User

-
- Posts: 16
- Joined: Tue Dec 25, 2012 7:38 pm
Return to PHP coding => General
Who is online
Users browsing this forum: Google [Bot] and 3 guests