class Url { /** * Generate an absolute URL to the given path. * * @param \Hyperf\HttpServer\Contract\RequestInterface $request * @param string $path * @param mixed $extra * @return string */ public static function to($request, $path, $extra = []) { // First we will check if the URL is already a valid URL. If it is we will not // try to generate a new one but will simply return the URL as is, which is // convenient since developers do not always have to check if it's valid. if (self::isValidUrl($path)) { return $path; } $tail = implode('/', array_map( 'rawurlencode', (array)self::formatParameters($extra)) ); $root = self::getReqFullHost($request); [$path, $query] = self::extractQueryString($path); return self::format( $root, '/' . trim($path .
Hyperf生成URL地址
最新推荐文章于 2024-08-09 17:50:34 发布
该博客介绍了如何在Hyperf框架中生成绝对URL。它包含一个名为`Url`的类,该类提供了多种方法,如`to()`用于生成URL,`isValidUrl()`用于检查URL的有效性,以及`extractQueryString()`和`format()`等辅助方法,处理URL的路径、查询字符串和格式化。
摘要由CSDN通过智能技术生成