Last active
April 28, 2017 12:28
-
-
Save FreakDev/1d95b245d956a288eccf to your computer and use it in GitHub Desktop.
PHP cli utilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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