PHP code example of noir / phpsh

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

    

noir / phpsh example snippets


use NoirApi\Phpsh\Condition;
use NoirApi\Phpsh\Script;

$condition = Condition::create('$i')->lessThan(10);

(new Script())
    ->set('i', 0)
    ->while($condition, function (Script $script){
        $script->echo('$i');
        $script->increment('i');
    })
    ->generate();

$condition = Condition::create()
    ->fileExists('/path/to/file')
    ->and()
    ->writable('/path/to/file');

(new Script())
    ->if($condition, function (Script $script){
        $script->printf("File found\n");
    })->else(function (Script $script){
        $script->printf("Oops!\n");
    })
    ->generate();
 sh
i=0
while [ $i -lt 10 ]; do
    echo -n $i
    let i+=1
done