【Laravel3.0.0源码阅读分析】uri类uri.php
发布日期:2021-06-30 20:44:44 浏览次数:2 分类:技术文章

本文共 1209 字,大约阅读时间需要 4 分钟。

* // Get the first segment of the request URI * $segment = URI::segment(1); * * // Get the second segment of the URI, or return a default value * $segment = URI::segment(2, 'Taylor'); * * * @param int $index * @param mixed $default * @return string */ public static function segment($index, $default = null) { static::current(); return array_get(static::$segments, $index - 1, $default); } /** * Set the URI segments for the request. * 设置请求的 URI 段。 * @param string $uri * @return void */ protected static function segments($uri) { $segments = explode('/', trim($uri, '/')); // array_diff-计算数组的差集 static::$segments = array_diff($segments, array('')); } /** * Remove a given value from the URI. * 从 URI 中删除给定值。 * @param string $uri * @param string $value * @return string */ protected static function remove($uri, $value) { return (strpos($uri, $value) === 0) ? substr($uri, strlen($value)) : $uri; } /** * Get the query string for the current request. * 获取当前请求的查询字符串。 * @return string */ protected static function query() { // http_build_query-生成 URL-encode 之后的请求字符串 return (count((array) $_GET) > 0) ? '?'.http_build_query($_GET) : ''; }}

 

github地址:     

转载地址:https://liushilong.blog.csdn.net/article/details/117397667 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:【Laravel3.0.0源码阅读分析】字符串类str.php
下一篇:【Laravel3.0.0源码阅读分析】url类url.php

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月14日 13时25分27秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章