PHP code example of willdurand / jsonp-callback-validator

1. Go to this page and download the library: Download willdurand/jsonp-callback-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/ */

    

willdurand / jsonp-callback-validator example snippets


$validator = new \JsonpCallbackValidator();

$validator->validate("JSONP.callback");
// returns `true`

$validator->validate("(function xss(x){evil()})");
// returns `false`

\JsonpCallbackValidator::validate("JSONP.callback");
// returns `true`

\JsonpCallbackValidator::validate("(function xss(x){evil()})");
// returns `false`