Link
Link
Represents a early hint link for HTTP/2 or HTTP/3.
This class is used to create and manage HTTP Link headers, which are used to provide hints to the client about resources that should be preloaded or prefetched. The Link header is typically used in the response headers of an HTTP request to inform the client about additional resources that may be needed for rendering the page.
Properties
href
public string $href
attributes
The relationship between the current document and the linked resource.
public array $attributes
Methods
__construct
public __construct(?string $href, ?string $rel = 'preload'): void
Parameters
Parameter | Type | Description |
---|---|---|
$href | string | |
$rel | string |
__toString
Converts the Link object to its string representation.
public __toString(): string
This method generates a string representation of the Link object in the format of an HTTP Link header. The href
property is used as the main URL, and any additional attributes are appended as key-value pairs.
attr
Sets an attribute for the link and returns the current instance.
public attr(string $name, string $value): void
Parameters
Parameter | Type | Description |
---|---|---|
$name | string | the name of the attribute to set |
$value | string | the value of the attribute to set |
Generated by Hazaar API Doc Generator on Tue, 06 May 2025 01:33:02 +0000