Common.php 489 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: lts
  5. * Date: 25/9/18
  6. * Time: 下午7:48
  7. */
  8. namespace app\common\constants;
  9. class Common
  10. {
  11. const YES = 1;
  12. const NO = 0;
  13. const STATUS_NORMAL = 'normal';
  14. const STATUS_HIDDEN = 'hidden';
  15. /**
  16. * 判断字符串是否为json格式
  17. * @param $string
  18. * @return bool
  19. */
  20. public static function isJson($string)
  21. {
  22. json_decode($string);
  23. return (json_last_error() == JSON_ERROR_NONE);
  24. }
  25. }