[UPHPU] beginner to DOM library

Jacob Wright jacwright at gmail.com
Wed Nov 8 11:14:53 MST 2006


>
> I'm trying to get acquainted with the PHP DOM library (php.net/dom)
> available in PHP5.  Any idea why I don't get more meaningful output
> from this code?
>

The reason why print_r did not give you more than what you got is (I think)
because PHP 5 now implements private and protected modifiers which hide the
internals of an object.  I may be wrong however.

When items use the Standard PHP Library (SPL) they don't show much with a
print_r as well.  I don't know if the DOM library uses SPL, but SPL is a set
of interfaces which, when implemented in a class, make an object behave like
an array.  This sounds slightly uninteresting at first, but when you start
thinking about what you can do with this, it gets more exciting.  For
example, you can have a database result set be an array even though it's
still an object.  And it doesn't hold the whole result set in memory, just
calls mysql_fetch_row() when you access the next item.  I've had some fun
with it.

Oh, sorry to digress.  Yeah perhaps it is because it uses SPL or perhaps
because of private settings.

Jacob

-- 
Jacob Wright
Within Code LLC


More information about the UPHPU mailing list