vendor/topthink/framework/src/think/route/dispatch/Url.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace think\route\dispatch;
use think\exception\HttpException;
use think\helper\Str;
use think\Request;
use think\route\Rule;
/**
* Url Dispatcher
*/
class Url extends Controller
{
public function __construct(Request $request, Rule $rule, $dispatch)
{
$this->request = $request;
$this->rule = $rule;
// 解析默认的URL规则
$dispatch = $this->parseUrl($dispatch);
parent::__construct($request, $rule, $dispatch, $this->param);
}
/**
* 解析URL地址
* @access protected
* @param string $url URL
* @return array
*/
protected function parseUrl(string $url): array
{
$depr = $this->rule->config('pathinfo_depr');
$bind = $this->rule->getRouter()->getDomainBind();
if ($bind && preg_match('/^[a-z]/is', $bind)) {
$bind = str_replace('/', $depr, $bind);
// 如果有域名绑定
$url = $bind . ('.' != substr($bind, -1) ? $depr : '') . ltrim($url, $depr);
}
$path = $this->rule->parseUrlPath($url);
if (empty($path)) {
return [null, null];
}
// 解析控制器
$controller = !empty($path) ? array_shift($path) : null;
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。