queue.init.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. if (!defined('IS_INITPHP')) exit('Access Denied!');
  3. /*********************************************************************************
  4. * InitPHP 3.8.1 国产PHP开发框架 - 工具库-队列
  5. *-------------------------------------------------------------------------------
  6. * 版权所有: CopyRight By initphp.com
  7. * 您可以自由使用该源码,但是在使用过程中,请保留作者信息。尊重他人劳动成果就是尊重自己
  8. *-------------------------------------------------------------------------------
  9. * Author:zhuli Dtime:2014-11-25
  10. ***********************************************************************************/
  11. class queueInit {
  12. private static $queue = array(); //存放队列数据
  13. /**
  14. * 队列-设置值
  15. * 使用方法:$this->getUtil('queue')->set('ccccccc');
  16. * @return string
  17. */
  18. public function set($val) {
  19. array_unshift(self::$queue, $val);
  20. return true;
  21. }
  22. /**
  23. * 队列-从队列中获取一个最早放进队列的值
  24. * 使用方法:$this->getUtil('queue')->get();
  25. * @return string
  26. */
  27. public function get() {
  28. return array_pop(self::$queue);
  29. }
  30. /**
  31. * 队列-队列中总共有多少值
  32. * 使用方法:$this->getUtil('queue')->count();
  33. * @return string
  34. */
  35. public function count() {
  36. return count(self::$queue);
  37. }
  38. /**
  39. * 队列-清空队列数据
  40. * 使用方法:$this->getUtil('queue')->clear();
  41. * @return string
  42. */
  43. public function clear() {
  44. return self::$queue = array();
  45. }
  46. }