joefallon/phphttp

简单的HTTP工具库。

v2.0.2 2015-02-05 18:42 UTC

This package is auto-updated.

Last update: 2024-09-25 23:14:11 UTC


README

Joe Fallon提供

这是一个有用的HTTP工具库,具有以下功能:

  • 完整的单元测试套件。
  • 可以集成到任何现有项目中。
  • 只需几分钟就能完全理解。

安装

使用Composer安装PhpDatabase是最简单的方式。创建以下composer.json文件并运行php composer.phar install命令来安装。

{
    "require": {
        "joefallon/phphttp": "*"
    }
}

用法

该库包含以下四个主要类:

  • Agent
  • HttpCodes
  • MimeType
  • PageRedirect

Agent

isBrowser()
isMobile()
isRobot()
isReferral()
getBrowserName()
getBrowserVersion()
getMobileDeviceName()
getRobotName()
getPlatformName()
getReferrer()
getAgentString()
getLanguages()
getCharsets()
acceptsLang($lang = 'en')
acceptsCharset($charset = 'utf-8')

HttpCodes

getCodeMessage($code)

MimeType

getMimeTypeFromFileName($filename = '')
getMimeTypeFromFileExtension($extension = '')

PageRedirect

getRedirectDestination()
setRedirectDestination($destination)
redirect()