PHP code example of takuya / php-shell

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

    

takuya / php-shell example snippets


$name = "takuya";
$ret = PHPShell::exec_command('echo $name', ['name'=>$name]);

$name = "takuy'a;curl -h ";
$name = escapeshellarg($name); // -> "'takuy'\''a;curl -h '" 

$url =  escapeshellarg("too long argument ..afasdfasdfasdfasdfawefadf");
$json = escapeshellarg(json_encode($object))
$cmd = 'curl -v -L $url -X POST --data $json';
var_dump($cmd);

$env_vars =  ['url'=>$url, 'json'=>$json];
foreach( $env_vars as $k=>$v ){
  putenv("$k=$v");
}
$ret = shell_exec('curl -v -L $url -X POST --data $json');