davestewart Posted July 16, 2009 Share Posted July 16, 2009 As part of a class I'm using to build tables, I've created a general Element class that holds a few properties and methods to output the essential bits of HTML tags, with an easy to use API: // properties $tag $content $class $style $attributes // constructor __construct($content = '', $class = '', $style = '', $attributes = '') // getters html() // wraps the following methods: open() content() close() It's about 50 lines of PHP. It could obviously be sub-classed for things like self closing tags, or specific tag types. My question is, does anyone know if native PHP simple XML would offer faster performance than my nice, simple, lean class? A typical table might hold 20 rows of 6 columns, so 120 or so operations. All my classes are also loaded in the same file. Cheers, Dave Quote Link to comment https://forums.phpfreaks.com/topic/166169-basic-html-tag-class/ Share on other sites More sharing options...
ignace Posted July 16, 2009 Share Posted July 16, 2009 To create a test case you must make sure that what you test is in both cases the same. $mt = microtime(true); ..test internal.. $rt = microtime(true) - $mt;//time the test needed to run $mt = microtime(true); ..test yours.. $rt = microtime(true) - $mt; All my classes are also loaded in the same file. Is not so good if you only need a few. Quote Link to comment https://forums.phpfreaks.com/topic/166169-basic-html-tag-class/#findComment-876374 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.