On 25 June 2025 13:21:22 BST, Andreas Hennings <andr...@dqxtech.net> wrote:
>On Wed, 25 Jun 2025 at 13:56, Christian Schneider <cschn...@cschneid.com> 
>wrote:
>>
>> I noticed that the "empty string for absence of value" was also used in 
>> DOMElement::getAttribute() but you can argue that the existence of 
>> DOMElement::hasAttribute() fills this gap.
>
>I think all this shows is that different parts of php were created by
>different people, or that somebody changed their mind over time.
>To me, "return null" would be preferable for
>DOMElement::getAttribute(). https://3v4l.org/QHXlA

In that example, PHP shouldn't be deciding its own behaviour at all, it should 
be following the DOM  standard. 

It turns out, the specification explicitly states that the return value should 
be null in this case, so arguably it's a bug that PHP's implementation does 
not: https://dom.spec.whatwg.org/#ref-for-dom-element-getattribute%E2%91%A0

Rowan Tommins
[IMSoP]

Reply via email to