Skip to Main Content
PHP 5 Kochbuch, Third Edition
book

PHP 5 Kochbuch, Third Edition

by David Sklar, Adam Trachtenberg, Carsten Lucke, Matthias Brusdeylins, Ulrich Speidel, Stephan Schmidt
September 2009
Intermediate to advanced content levelIntermediate to advanced
912 pages
48h 11m
German
O'Reilly Verlag
Content preview from PHP 5 Kochbuch, Third Edition

13.5 Eine URL über eine beliebige HTTP-Methode abrufen

Problem

Sie möchten eine URL über eine exotischere Methode als get oder post anfordern, put oder delete beispielsweise.

Lösung

Setzen Sie, wie beim Einsatz von post, die Stream-Kontextoptionen method und content, wenn Sie den http-Stream nutzen, wie Sie es in Listing 13.1 sehen.

<?php $url = 'http://www.example.com/put.php'; // Der Request-Body in beliebigem Format $body = '<menu> <dish type="appetizer">Hühnersuppe</dish> <dish type="main course">Frittiertes Affenhirn</dish> </menu>'; $options = array('method' => 'PUT', 'content' => $body); // Den Stream-Kontext erzeugen $context = stream_context_create(array('http' => $options)); // Den Kontext an file_get_contents() übergeben print file_get_contents($url, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP programmieren unter Windows

PHP programmieren unter Windows

Arno Hollosi
CSS Kochbuch, 3rd Edition

CSS Kochbuch, 3rd Edition

Joergen Lang, Christopher Schmitt

Publisher Resources

ISBN: 9783868993271Purchase book