Overview

Namespaces

  • Kotchasan
    • Cache
    • Database
    • Http
    • Log
    • Orm
  • None
  • PHP
  • Psr
    • Cache
    • Http
      • Message
    • Log

Classes

  • AbstractMessage
  • AbstractRequest
  • Message
  • NotFound
  • Request
  • Response
  • Stream
  • UploadedFile
  • Uri
  • Overview
  • Namespace
  • Class
  • Tree

Class Uri

Class สำหรับจัดการ Uri (PSR-7)

Kotchasan\KBase
Extended by Kotchasan\Http\Uri implements Psr\Http\Message\UriInterface
Namespace: Kotchasan\Http
Author: Goragod Wiriya admin@goragod.com
Since: 1.0
Located at Kotchasan/Http/Uri.php
Methods summary
public
# __construct( string $scheme, $host, $path = '/', $query = '', $port = null, $user = '', $pass = '', $fragment = '' )

Create a new Uri

Create a new Uri

Parameters

$scheme
$uri
$host
$path
$query
$port
$user
$pass
$fragment

Throws

InvalidArgumentException
ถ้า Uri ไม่ถูกต้อง
public string
# __toString( )

magic function ส่งออกคลาสเป็น String

magic function ส่งออกคลาสเป็น String

Returns

string

Implementation of

Psr\Http\Message\UriInterface::__toString()
public string
# createBackUri( array $query_string )

ฟังก์ชั่นสร้าง URL สำหรับส่งต่อ Query string จากหน้าหนึ่งไปยังอีกหน้าหนึ่ง เพื่อให้สามารถสร้าง URL ที่สามารถส่งกลับไปยังหน้าเดิมได้โดย ฟังก์ชั่น back() ลบรายการที่ เป็น null ออก

ฟังก์ชั่นสร้าง URL สำหรับส่งต่อ Query string จากหน้าหนึ่งไปยังอีกหน้าหนึ่ง เพื่อให้สามารถสร้าง URL ที่สามารถส่งกลับไปยังหน้าเดิมได้โดย ฟังก์ชั่น back() ลบรายการที่ เป็น null ออก

Parameters

$query_string

Returns

string
public static static
# createFromGlobals( )

สร้าง Uri จากตัวแปร $_SERVER

สร้าง Uri จากตัวแปร $_SERVER

Returns

static

Throws

InvalidArgumentException
ถ้า Uri ไม่ถูกต้อง
public static static
# createFromUri( string $uri )

สร้างคลาสจากลิงค์

สร้างคลาสจากลิงค์

Parameters

$uri

Returns

static

Throws

InvalidArgumentException
ถ้า $uri ไม่ถูกต้อง
public string
# getAuthority( )

ตืนค่า authority ของ Uri [user-info@]host[:port]

ตืนค่า authority ของ Uri [user-info@]host[:port]

Returns

string

Implementation of

Psr\Http\Message\UriInterface::getAuthority()
public string
# getBack( string $url, array $query_string = array() )

แปลง GET เป็น query string สำหรับการส่งกลับไปหน้าเดิม ที่มาจากการโพสต์ด้วยฟอร์ม

แปลง GET เป็น query string สำหรับการส่งกลับไปหน้าเดิม ที่มาจากการโพสต์ด้วยฟอร์ม

Parameters

$url
URL ที่ต้องการส่งกลับ เช่น index.php
$query_string
(option) query string ที่ต้องการส่งกลับไปด้วย array('key' => 'value', ...)

Returns

string
URL+query string
public string
# getFragment( )

คืนค่า fragment (ข้อมูลหลัง # ใน Uri) ของ Uri

คืนค่า fragment (ข้อมูลหลัง # ใน Uri) ของ Uri

Returns

string

Implementation of

Psr\Http\Message\UriInterface::getFragment()
public string
# getHost( )

คืนค่า Hostname ของ Uri เช่น domain.tld

คืนค่า Hostname ของ Uri เช่น domain.tld

Returns

string

Implementation of

Psr\Http\Message\UriInterface::getHost()
public string
# getPath( )

คืนค่า path ของ Uri เช่น /kotchasan

คืนค่า path ของ Uri เช่น /kotchasan

Returns

string

Implementation of

Psr\Http\Message\UriInterface::getPath()
public null|integer
# getPort( )

คืนค่าหมายเลข Port ของ Uri ไม่ระบุหรือเป็น default port (80,433) คืนค่า null

คืนค่าหมายเลข Port ของ Uri ไม่ระบุหรือเป็น default port (80,433) คืนค่า null

Returns

null|integer

Implementation of

Psr\Http\Message\UriInterface::getPort()
public string
# getQuery( )

คืนค่า query string (ข้อมูลหลัง ? ใน Uri) ของ Uri

คืนค่า query string (ข้อมูลหลัง ? ใน Uri) ของ Uri

Returns

string

Implementation of

Psr\Http\Message\UriInterface::getQuery()
public string
# getScheme( )

คืนค่า scheme ของ Uri ไม่รวม :// เช่น http, https.

คืนค่า scheme ของ Uri ไม่รวม :// เช่น http, https.

Returns

string

Implementation of

Psr\Http\Message\UriInterface::getScheme()
public string
# getUserInfo( )

คืนค่าข้อมูล user ของ Uri user[:password]

คืนค่าข้อมูล user ของ Uri user[:password]

Returns

string

Implementation of

Psr\Http\Message\UriInterface::getUserInfo()
public string
# pagination( integer $totalpage, integer $page, integer $maxlink = 9 )

ฟังก์ชั่นแสดงผลตัวแบ่งหน้า

ฟังก์ชั่นแสดงผลตัวแบ่งหน้า

Parameters

$totalpage
จำนวนหน้าทั้งหมด
$page
หน้าปัจจุบัน
$maxlink
(optional) จำนวนตัวเลือกแบ่งหน้าสูงสุด ค่าปกติ 9

Returns

string
public string
# paramsToQuery( array $params, boolean $encode )

ฟังก์ชั่นแปลง Queryparams เป็น Querystring

ฟังก์ชั่นแปลง Queryparams เป็น Querystring

Parameters

$params
$encode
false เชื่อม Querystring ด้วย &, true เชื่อม Querystring ด้วย &

Returns

string
public array
# parseQueryParams( string $query = null )

ฟังก์ชั่น แยก Querystring ออกเป็น array

ฟังก์ชั่น แยก Querystring ออกเป็น array

Parameters

$query

Returns

array
public string
# postBack( string $url, array $query_string = array() )

แปลง POST เป็น query string สำหรับการส่งกลับไปหน้าเดิม ที่มาจากการโพสต์ด้วยฟอร์ม คืนค่า URL+query string

แปลง POST เป็น query string สำหรับการส่งกลับไปหน้าเดิม ที่มาจากการโพสต์ด้วยฟอร์ม คืนค่า URL+query string

Parameters

$url
URL ที่ต้องการส่งกลับ เช่น index.php
$query_string
(option) query string ที่ต้องการส่งกลับไปด้วย array('key' => 'value', ...)

Returns

string
public static
# withFragment( string $fragment )

กำหนดค่า fragment คืนค่า Object ใหม่

กำหนดค่า fragment คืนค่า Object ใหม่

Parameters

$fragment

Returns

static

Throws

InvalidArgumentException
ถ้า fragment ไม่ถูกต้อง

Implementation of

Psr\Http\Message\UriInterface::withFragment()
public static
# withHost( string $host )

กำหนดชื่อ host คืนค่า Object ใหม่

กำหนดชื่อ host คืนค่า Object ใหม่

Parameters

$host
ชื่อ host

Returns

static

Throws

InvalidArgumentException
for invalid hostnames

Implementation of

Psr\Http\Message\UriInterface::withHost()
public static
# withParams( array $params, boolean $encode = false )

ฟังก์ชั่นแทนที่ Query params ลงใน URL

ฟังก์ชั่นแทนที่ Query params ลงใน URL

Parameters

$params
$encode
false (default) เชื่อม Querystring ด้วย &, true เชื่อม Querystring ด้วย &

Returns

static
public static
# withoutParams( string|array $names, boolean $encode = false )

ฟังก์ลบ Query params ออกจาก URL

ฟังก์ลบ Query params ออกจาก URL

Parameters

$names
ชื่อของ attributes ที่ต้องการลบ
$encode
false (default) เชื่อม Querystring ด้วย &, true เชื่อม Querystring ด้วย &

Returns

static
public static
# withPath( string $path )

กำหนดชื่อ path path ต้องเริ่มต้นด้วย / เช่น /kotchasan หรือเป็นค่าว่าง ถ้าเป็นรากของโดเมน คืนค่า Object ใหม่

กำหนดชื่อ path path ต้องเริ่มต้นด้วย / เช่น /kotchasan หรือเป็นค่าว่าง ถ้าเป็นรากของโดเมน คืนค่า Object ใหม่

Parameters

$path
ชื่อ path

Returns

static

Throws

InvalidArgumentException
for invalid paths

Implementation of

Psr\Http\Message\UriInterface::withPath()
public static
# withPort( null|integer $port )

กำหนดค่า port คืนค่า Object ใหม่

กำหนดค่า port คืนค่า Object ใหม่

Parameters

$port
หมายเลข port 1- 65535 หรือ null

Returns

static

Throws

InvalidArgumentException
ถ้า port ไม่ถูกต้อง

Implementation of

Psr\Http\Message\UriInterface::withPort()
public static
# withQuery( string $query )

กำหนดค่า query string คืนค่า Object ใหม่

กำหนดค่า query string คืนค่า Object ใหม่

Parameters

$query

Returns

static

Throws

InvalidArgumentException
ถ้า query string ไม่ถูกต้อง

Implementation of

Psr\Http\Message\UriInterface::withQuery()
public static
# withoutQuery( array $query )

ลบ query string คืนค่า Object ใหม่

ลบ query string คืนค่า Object ใหม่

Parameters

$query
array('q1' => 'value1', 'q2' => 'value2')

Returns

static
public static
# withScheme( string $scheme )

กำหนดค่า scheme ของ Uri คืนค่า Object ใหม่

กำหนดค่า scheme ของ Uri คืนค่า Object ใหม่

Parameters

$scheme
http หรือ https หรือค่าว่าง

Returns

static

Throws

InvalidArgumentException
ถ้าไม่ใช่ ค่าว่าง http หรือ https

Implementation of

Psr\Http\Message\UriInterface::withScheme()
public static
# withUserInfo( string $user, string $password = null )

กำหนดข้อมูล user ของ Uri คืนค่า Object ใหม่

กำหนดข้อมูล user ของ Uri คืนค่า Object ใหม่

Parameters

$user
$password

Returns

static

Implementation of

Psr\Http\Message\UriInterface::withUserInfo()
Properties summary
protected string $fragment

Uri fragment หลัง #

Uri fragment หลัง #

# ''
protected string $host

Uri host

Uri host

# ''
protected string $path

Uri path

Uri path

# ''
protected integer $port

Uri port

Uri port

#
protected string $query

Uri query string หลัง ?

Uri query string หลัง ?

# ''
protected string $scheme

Uri scheme

Uri scheme

# ''
protected string $userInfo

Uri user info

Uri user info

# ''
Properties inherited from Kotchasan\KBase
$cfg, $request
Kotchasan API documentation generated by ApiGen