note 104767 added to function.explode
| From: | jeffmixpute at osu1 dot php dot net | Date: | Wed, 06 Jul 2011 11:06:15 +0000 |
| Subject: | note 104767 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181277@lists.php.net to get a copy of this message | ||
<?php
// a simple client (explode will used in service)
$url = "http://localhost/~student/Sites/rest-service.php";
$chget = curl_init();
$chpost = curl_init();
$chput = curl_init();
$chdelete = curl_init();
curl_setopt($chget, CURLOPT_URL, $url . "/ressource63");
curl_setopt($chget, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($chget);
echo $response;
$data = <<<XML
<xml><name>chris</name></xml>
XML;
curl_setopt($chpost, CURLOPT_URL, $url);
curl_setopt($chpost, CURLOPT_POST, true);
curl_setopt($chpost, CURLOPT_RETURNTRANSFER, true);
curl_setopt($chpost, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($chpost);
echo $response;
curl_setopt($chput, CURLOPT_URL, $url);
curl_setopt($chput, CURLOPT_PUT, true);
curl_setopt($chput, CURLOPT_RETURNTRANSFER, true);
curl_setopt($chput, CURLOPT_INFILE, fopen("./file.txt", "r"));
curl_setopt($chput, CURLOPT_INFILESIZE, 100); // size of the file in bytes
$response = curl_exec($chput);
echo $response;
curl_setopt($chdelete, CURLOPT_URL, $url . "/ressource56");
curl_setopt($chdelete, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($chdelete, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($chdelete);
echo $response;
curl_close($chget);
curl_close($chpost);
curl_close($chput);
curl_close($chdelete);
?>
<?php
// ... and a simple service to make some tests
$path = $_SERVER["PATH_INFO"];
$daten = explode("/", $path); // explode in action!
if($_SERVER["REQUEST_METHOD"] == "GET") {
echo "get: " . $daten[1] . "<br/>\n";
return;
}
elseif($_SERVER["REQUEST_METHOD"] == "POST") {
$xml = simplexml_load_string(file_get_contents("php://input"));
echo "post: " . $xml->name . "<br/>\n";
return;
}
elseif($_SERVER["REQUEST_METHOD"] == "PUT") {
echo "put: " . file_get_contents("php://input") . "<br/>\n";
return;
}
elseif($_SERVER["REQUEST_METHOD"] == "DELETE") {
echo "del: " . $daten[1] . "<br/>\n";
return;
}
?>
----
Server IP: 212.124.37.9
Probable Submitter: 91.194.84.122
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- https://master.php.net/note/edit/104767
Del: integrated -- https://master.php.net/note/delete/104767/integrated
Del: useless -- https://master.php.net/note/delete/104767/useless
Del: bad code -- https://master.php.net/note/delete/104767/bad+code
Del: spam -- https://master.php.net/note/delete/104767/spam
Del: non-english -- https://master.php.net/note/delete/104767/non-english
Del: in docs -- https://master.php.net/note/delete/104767/in+docs
Del: other reasons-- https://master.php.net/note/delete/104767
Reject -- https://master.php.net/note/reject/104767
Search -- https://master.php.net/manage/user-notes.php