PHP code example of a.emelyanenko / bracket-validator

1. Go to this page and download the library: Download a.emelyanenko/bracket-validator 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/ */

    

a.emelyanenko / bracket-validator example snippets


$service = new BracketValidatorService();

header('Content-Type: application/json; charset=utf-8');

try {
    $input = $_POST['string'] ?? '';
    $service->validate($input);

    http_response_code(200);
    echo "200 OK: Всё хорошо";

} catch (InvalidBracketsException $e) {
    http_response_code(400);
    echo "400 Bad Request: " . $e->getMessage();

} catch (Throwable $e) {
    http_response_code(500);
    echo "500 Internal Server Error";
}