The setAttribute() method sets the specified attribute on the element. If the attribute already exists, its value is updated. If the value is null, the attribute is set to an empty string.
Description
public ElementNode::setAttribute(string $name, \Stringable|string|null $value): static
Parameters
name
The name of the attribute to set.
value
The value of the attribute. Can be a string, null, or an object that implements \Stringable. If null, the value will be treated as an empty string.
Return Value
Returns the current instance (static), allowing for method chaining.
Exceptions
None