PHP Classes

File: example/index.php

Recommend this page to a friend!
  Classes of Muhammad Umer Farooq   PHP HTTP Client Request   example/index.php   Download  
File: example/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP HTTP Client Request
Process and send HTTP requests to Web servers
Author: By
Last change:
Date: 5 years ago
Size: 1,133 bytes


Class file image Download

require '../vendor/autoload.php';

$request = new Lablnet\Request();

// Get the value of _GET['var']
$var = $request->getQuery('var');
//it print the get request

// Get the value of $_POST['id']
if ($request->isPost()) {
$id = $request->getPost('id');

$config = [
'code' => 200,
'headers' => [
'Content-Type' => 'text/html'

$response = new Lablnet\Response($config);
$response->setBody('This is a plain text file.');


//Redirect to other page/site.
//(new Lablnet\Redirect(''));
//Using the cURL client
//Send request to login page with post method
$request = $request->curl("","POST");
//Set transfer and return header
//Set the fields
'username' => 'your-username',
'password' => 'your-password'
//Send the request
// return => 200
$statusCode = $request->getCode();
// Display the body of the returned response
echo "<br\>".$request->getBody();