Cli.php 664 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Qii\Response;
  3. use Qii\Base\Response;
  4. class Cli extends Response
  5. {
  6. public function __construct($body = null)
  7. {
  8. $this->body = $body;
  9. }
  10. /**
  11. * Magic __toString functionality
  12. *
  13. * @return string
  14. */
  15. public function __toString()
  16. {
  17. return $this->body;
  18. }
  19. /**
  20. * 在windows cmd 情况下的中文输出乱码问题
  21. * @param string $string
  22. * @return bool|int
  23. */
  24. public function stdout($string)
  25. {
  26. if(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') $string = iconv('utf-8', 'gbk', $string);
  27. fwrite(\STDOUT, $string);
  28. }
  29. }