承接 folded/url 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

folded/url

Composer 安装命令:

composer require folded/url

包简介

URL utilities for your web app.

README 文档

README

URL utilities for your PHP web app.

Packagist License Packagist PHP Version Support Packagist Version Build Status Maintainability TODOs

Summary

About

I created this library to have an easy way to use common URL functions like getting the current URL, in a standalone way.

Folded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.

Features

Requirements

  • PHP version >= 7.4.0
  • Composer installed

Installation

In your project root folder, run this command:

composer require folded/url

Examples

1. Check if the current URL matches a given URL

In this example, we will check if the current URL matches a given URL.

use function Folded\currentUrlIs;

if (currentUrlIs("/about-us")) {
  echo "We are on page /about-us";
} else {
  echo "We are somewhere else";
}

2. Get the current URL

In this example, we will get the current URL, including the server protocol, domain, and eventuals query strings.

use function Folded\getCurrentUrl;

echo getCurrentUrl(); // "https://example.com/about-us?page=1"

3. Get a query string value by key name

In this example, we will get the value of a query string by its key name.

use function Folded\getQueryString;

// Assuming we are on page https://example.com/about-us?page=1

echo getQueryString("page"); // "1"

If the query string is not present, the function will throw an exception. To avoid this, you can use the second parameter to provide a fallback value in case the query string is not found.

use function Folded\getQueryString;

echo getQueryString("page", "1");

4. Get all the query strings

In this example, we will get all the query strings as an associative array.

use function Folded\getQueryStrings;

// Assuming we are on page https://example.com/about-us?page=1&view=list

$queryStrings = getQueryStrings();

foreach ($queryStrings as $key => $value) {
  echo "value of $key is $value";
}

5. Check if a query string is present by key name

In this example, we will check if a query string is present.

use function Folded\hasQueryString;

if (hasQueryString("page")) {
  echo "We can grab its value";
} else {
  echo "Do something else without it";
}

Version support

7.3 7.4 8.0
v0.1.0 ✔️

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固