PHP code example of apsxj / json

1. Go to this page and download the library: Download apsxj/json library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

apsxj / json example snippets


// For example, from the root directory...



// unwrap the Response class from the apsxj\json namespace
use apsxj\json\Response;

// Create a new response
$response = new Response();

// Add some data
$response->appendData(
  array(
    'method' => 'test',
    'result' => 'success'
  )
);

// Render the response
$response->render();



// unwrap the Response class from the apsxj\json namespace
use apsxj\json\Response;

// Create a new response
$response = new Response();

// Add the error
$response->appendError(
  404,
  'Not Found',
  'The requested resource was not found'
);

// Render the response
$response->render();