PHP code example of rasuvaeff / doc-exec

1. Go to this page and download the library: Download rasuvaeff/doc-exec 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/ */

    

rasuvaeff / doc-exec example snippets

 doc-exec
2 + 3; // => 5
intdiv(1, 0); // throws DivisionByZeroError
echo "done"; // outputs done
network_call(); // skip: hits a real API
 doc-exec
$double = function (int $n): int {
    return $n * 2;
};

if ($double(4) > 5) {
    $size = 'big';
} else {
    $size = 'small';
}

$size; // => 'big'
 doc-exec
2 + 3; // => 5
 doc-exec
use Rasuvaeff\DocExec\MarkdownExtractor;

$markdown = "
 doc-exec
function riskyDivide(int $a, int $b): int
{
    return intdiv($a, $b);
}

riskyDivide(1, 0); // throws DivisionByZeroError
echo "done"; // outputs done
1 + 1; // skip: illustrative only, never executed