Link
Link
Represents a early hint link for HTTP/2 or HTTP/3.
class LinkThis 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 $hrefattributes
The relationship between the current document and the linked resource.
public array $attributesMethods
__construct
Constructs a Link object for use in HTTP Link headers.
public __construct(?string $href, ?string $rel = 'preload'): voidInitializes the link with the provided href and relationship type (rel). Sets the rel attribute to 'preload' by default.
Parameters
| Parameter | Type | Description |
|---|---|---|
$href | string | the hyperlink reference (URL) for the link |
$rel | string | the relationship type for the link (default: 'preload') |
__toString
Converts the Link object to its string representation.
public __toString(): stringThis 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): voidParameters
| 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, 21 Apr 2026 04:00:25 +0000