PHP code example of smuuf / primi
1. Go to this page and download the library: Download smuuf/primi 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/ */
smuuf / primi example snippets
ext = new \Smuuf\Primi\Context;
$interpreter = new \Smuuf\Primi\Interpreter($context);
try {
// Let the interpreter run a source code.
$interpreter->run('a = 1; b = a + 2; c = "some string"; d = c + " extra thing";');
// Get defined variables from primary context and print them.
foreach ($context->getVariables() as $name => $value) {
printf("%s (%s) ... %s\n", $name, $value::TYPE, $value->getCoreValue());
}
} catch (\Smuuf\Primi\ErrorException $e) {
die($e->getMessage());
}