In the php docs it says:
Return Values
The value of the attribute, or an empty string if no attribute with the given name is found.
Does anybody know the reason for returning an empty string instead of just NULL?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The point is that the DOM specification is not platform-specific. It was written to be implemented in a wide variety of programming languages, so it tends not to assume the existence of types such as
null. The W3C can assume the existence of a string type, so it’s safe to use an empty string.So the specification reads as this:
So a string is the expected type on a cross-platform basis. PHP’s DOMDocument conforms to this.