PHP Classes

File: test/test.php

Recommend this page to a friend!
  Packages of Nikos M.   Eazy HTTP   test/test.php   Download  
File: test/test.php
Role: Auxiliary script
Content type: text/plain
Description: Configuration script
Class: Eazy HTTP
Send HTTP requests defined with a fluent interface
Author: By
Last change: Update of test/test.php
Date: 1 year ago
Size: 794 bytes
 

Contents

Class file image Download
<?php
// run "php -S localhost:9000 test-server.php"
$method = isset($_SERVER['REQUEST_METHOD']) ? strtoupper((string)$_SERVER['REQUEST_METHOD']) : 'GET';

header('Content-Type: text/plain; charset=UTF-8', true, 200);
if ('POST' === $method)
{
    setcookie("test_cookie", 'cookie value', time()+3600);  /* expire in 1 hour */
    echo "COOKIE:";
    echo json_encode($_COOKIE)."\n\n";
    echo "POST:";
    echo json_encode($_POST)."\n\n";
    echo "FILES:";
    echo json_encode($_FILES)."\n\n";
}
elseif ('GET' === $method)
{
    setcookie("test_cookie", 'cookie value', time()+3600);  /* expire in 1 hour */
    echo "COOKIE:";
    echo json_encode($_COOKIE)."\n\n";
    echo "GET:";
    echo json_encode($_GET)."\n\n";
}
else
{
    echo "METHOD: $method\n\n";
}