Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. /*
  2. * Description: Simple IO class for php CLI
  3. * Author: Mads Aune
  4. */
  5.  
  6. if(!defined("STDIN")) { define('STDIN', fopen('php://stdin', 'r')); }
  7.  
  8. class CLI {
  9. public static function getLine($prompt = '') {
  10. echo $prompt . "> ";
  11. return trim(fgets(STDIN));
  12. }
  13.  
  14. public static function getInt($prompt = '') {
  15. echo $prompt . "> ";
  16. $input = (int) trim(fgets(STDIN));
  17. return is_numeric($input) ? $input : false;
  18. }
  19.  
  20. public static function say($text = '') {
  21. echo $text;
  22. }
  23.  
  24. public static function sayLine($text = '') {
  25. echo $text . "\n";
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement