Request.php 594 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace common\fm;
  3. use Yii;
  4. use yii\helpers\StringHelper;
  5. use yii\helpers\ArrayHelper;
  6. class Request extends StringHelper
  7. {
  8. public static function Referer($modules = '')
  9. {
  10. $refArr = parse_url(Yii::$app->request->getReferrer());//上一页的URL
  11. $hostInfo = parse_url(Yii::$app->request->hostInfo); //当前URL
  12. if (!empty($refArr['host']) && $refArr['host'] == $hostInfo['host']) {
  13. return 'javascript:history.back(-1)';
  14. }
  15. if ($modules != '') {
  16. return '/' . $modules;
  17. }
  18. return '/';
  19. //
  20. }
  21. }