|
|
This work is licensed under a Creative Commons |
PHP is a technology which can be used on the server side to process HTTP requests. PHP can access other web-based services by accessing them through various interfaces; and it can also be used to implement Web-based services by returning XML instead of HTML. This means that PHP can be used as a simple platform for Web-based services, both for the client and for the server side.
.php or .asp URIs)
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
<?php … ?> is interpreted as PHP code<?php phpinfo(); ?>
<html>
<head>
<title>Get Request Headers</title>
</head>
<body>
<table>
<?php
foreach ( $_SERVER as $index=>$value ) {
if ( strpos($index, "HTTP_") === 0 ) {
echo "<tr><th align='right' valign='top'>" . substr($index,5) . "</th><td>$value</td></tr>"; } } ?>
</table>
</body>
</html>
(try shift-reload vs. no-shift-reload)
<html>
<head>
<title>Get Request Headers</title>
</head>
<body>
<table>
<?php
foreach ( $_SERVER as $index=>$value ) {
echo "<tr><th align='right' valign='top'>$index</th><td>$value</td></tr>"; } ?>
</table>
</body>
</html>
(try adding a query string to the script's URI)
system command<pre>
<?php system("ls -lasg"); ?>
</pre>
<pre>
<?php system("ls -" . $_SERVER['QUERY_STRING']); ?>
</pre>
system as well<?php
include("HttpClient.class.php");
$pageContent = HttpClient::quickGet('http://dret.net/lectures/services-fall06/');
$highlightedContent = str_replace($_SERVER['QUERY_STRING'], "<span style='background-color : yellow'>" . $_SERVER['QUERY_STRING'] . "</span>", $pageContent);
echo $highlightedContent;
?>