Skip to content

Instantly share code, notes, and snippets.

@FreakDev
Last active April 28, 2017 12:28
Show Gist options
  • Save FreakDev/1d95b245d956a288eccf to your computer and use it in GitHub Desktop.
Save FreakDev/1d95b245d956a288eccf to your computer and use it in GitHub Desktop.
PHP cli utilities
<?php
/**
* read input from std in
*/
function readInput ($str = "") {
echo $str;
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
fclose($handle);
return trim($line);
}
/**
* output string to stdout with a line ending char
*/
function writeLn($str) {
echo $str . "\n";
}
/**
* clean display
*/
function clear() {
exec('reset');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment