Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Christian Stocker's Blog:
Calling PHP function from XSLT vs. native XSLT functions benchmark
Mar 27, 2006 @ 12:55:47

One of the more underused thechnologies to come along these days is XSLT - that powerful langauge to style XML documents in a simple, "more correct" kind of way (seperation of data and layout). Most languages have support for this combination, including PHP - but what's the best way to combine PHP and XSLT? Christian Stocker took a look in this new post on the Bitflux blog.

After Rob's idea from yesterday about using XMLReader within XSLT I was wondering, how much of a slowdown calling PHP functions from XSLT is.

I wrote 4 different XSLT templates, which do a simple substring. One with the xslt function "substring", one with just calling the native PHP function "substr" and one with calling a user-defined function (which is also just calling "substr"). I called this 100 times (with one of those great recursive self-calling xslt-templates) and did call the "transformToXML" function a 100 times for each stylesheet. This means, we called the function 10'000 times for each benchmark run.

His bases the results off of a sample with no function call at all and, but running it through 100 times, came up with results that weren't all that surprising. In order of speed, the ranking (shortest time first) was: no call, xslt only, php native, and php userland. Using the PHP functions from inside of XSLT made the test quite a bit slower, but, as he notes, most users won't be running recursions of 100 each time they run a script.

tagged: XSLT native functions user-defined substring substr XSLT native functions user-defined substring substr

Link:

Christian Stocker's Blog:
Calling PHP function from XSLT vs. native XSLT functions benchmark
Mar 27, 2006 @ 12:55:47

One of the more underused thechnologies to come along these days is XSLT - that powerful langauge to style XML documents in a simple, "more correct" kind of way (seperation of data and layout). Most languages have support for this combination, including PHP - but what's the best way to combine PHP and XSLT? Christian Stocker took a look in this new post on the Bitflux blog.

After Rob's idea from yesterday about using XMLReader within XSLT I was wondering, how much of a slowdown calling PHP functions from XSLT is.

I wrote 4 different XSLT templates, which do a simple substring. One with the xslt function "substring", one with just calling the native PHP function "substr" and one with calling a user-defined function (which is also just calling "substr"). I called this 100 times (with one of those great recursive self-calling xslt-templates) and did call the "transformToXML" function a 100 times for each stylesheet. This means, we called the function 10'000 times for each benchmark run.

His bases the results off of a sample with no function call at all and, but running it through 100 times, came up with results that weren't all that surprising. In order of speed, the ranking (shortest time first) was: no call, xslt only, php native, and php userland. Using the PHP functions from inside of XSLT made the test quite a bit slower, but, as he notes, most users won't be running recursions of 100 each time they run a script.

tagged: XSLT native functions user-defined substring substr XSLT native functions user-defined substring substr

Link:

DevShed:
User-defined Interfaces in PHP 5 - Building a Page Generator
Jan 10, 2006 @ 13:29:09

DevShed has posted thier final part in the "User-defined Interfaces in PHP" series today - "Building a Page Generator".

In this final part of the series on user-defined interfaces in PHP 5, Alejandro puts all of the classes created in the previous articles together to work as a page generator. This allows complex page generation to be translated into a more flexible process through an object-based solution.

With reference to this final part of the series, I shall put all of the classes to work together into a full-featured example, by including the already familiar (X)HTML widgets in conjunction with the pair of MySQL-processing classes, in order to integrate both types of objects into a page generator class. As a result, complex web page generation can be translated into a more flexible process tackled through an object-based solution.

Combining the efforts from the two previous articles in the series, they build a class that takes in the data it needs and builds out the page accordingly. The PageGenerator class does all of the work for you, making object-based pages a simple process...

tagged: user-defined interfaces page generator object-based user-defined interfaces page generator object-based

Link:

DevShed:
User-defined Interfaces in PHP 5 - Building a Page Generator
Jan 10, 2006 @ 13:29:09

DevShed has posted thier final part in the "User-defined Interfaces in PHP" series today - "Building a Page Generator".

In this final part of the series on user-defined interfaces in PHP 5, Alejandro puts all of the classes created in the previous articles together to work as a page generator. This allows complex page generation to be translated into a more flexible process through an object-based solution.

With reference to this final part of the series, I shall put all of the classes to work together into a full-featured example, by including the already familiar (X)HTML widgets in conjunction with the pair of MySQL-processing classes, in order to integrate both types of objects into a page generator class. As a result, complex web page generation can be translated into a more flexible process tackled through an object-based solution.

Combining the efforts from the two previous articles in the series, they build a class that takes in the data it needs and builds out the page accordingly. The PageGenerator class does all of the work for you, making object-based pages a simple process...

tagged: user-defined interfaces page generator object-based user-defined interfaces page generator object-based

Link:

DevShed:
User-defined Interfaces in PHP 5 - Turning MySQL Classes into Interface Implementers
Jan 02, 2006 @ 22:18:06

DevShed has posted the third part of their "User-defined Interfaces in PHP5" series today, this one focusing on the conversion of MySQL classes into interface implementors.

Returning to this part of the series, I'll demonstrate how useful interfaces can be, by implementing the "HTMLRenderer" interface on a couple of MySQL processing classes that have nothing in common with the (X)HTML widgets explained in the previous tutorial. In this way, by the end of this article you'll have a decent background for working with interfaces as well as a clear idea about its concrete implementation in PHP applications.

By using the code generated in the previous tutorial of the series, they show you how to use it in a more real-life situation, rendering the results in an HTML automatically...

tagged: user-defined interface mysql implement display HTML table user-defined interface mysql implement display HTML table

Link:

DevShed:
User-defined Interfaces in PHP 5 - Turning MySQL Classes into Interface Implementers
Jan 02, 2006 @ 22:18:06

DevShed has posted the third part of their "User-defined Interfaces in PHP5" series today, this one focusing on the conversion of MySQL classes into interface implementors.

Returning to this part of the series, I'll demonstrate how useful interfaces can be, by implementing the "HTMLRenderer" interface on a couple of MySQL processing classes that have nothing in common with the (X)HTML widgets explained in the previous tutorial. In this way, by the end of this article you'll have a decent background for working with interfaces as well as a clear idea about its concrete implementation in PHP applications.

By using the code generated in the previous tutorial of the series, they show you how to use it in a more real-life situation, rendering the results in an HTML automatically...

tagged: user-defined interface mysql implement display HTML table user-defined interface mysql implement display HTML table

Link:

DevShed:
User-defined interfaces in PHP 5 - Implementing (X)HTML Widgets
Dec 27, 2005 @ 12:46:15

DevShed has the latest in their "User-defined interfaces in PHP5" series posted today - Implementing (X)HTML Widgets - a look at how to create bits of reusable code (widgets) to help make your development process more object oriented.

In this second part of the series, you will learn the basics of object-oriented web page generation through the use of (X)HTML widgets. You will also see how objects implement the "HTMLRenderer" interface to explicitly define its functionality by using the "toHTML()" method.

The drawback to the "widget" approach resides mainly in the performance cost of creating many objects for rendering a web document, even if they only exist until the page has finished displaying.

They jump right in, creating the base for their widgets, the HTMLRenderer interface. From there, they show how to create the widget classes and interface them in with the HTMLRenderer (which provides a generic interface and the toHTML function for the widget subclasses).

tagged: user-defined interface php5 (x)html widget user-defined interface php5 (x)html widget

Link:

DevShed:
User-defined interfaces in PHP 5 - Implementing (X)HTML Widgets
Dec 27, 2005 @ 12:46:15

DevShed has the latest in their "User-defined interfaces in PHP5" series posted today - Implementing (X)HTML Widgets - a look at how to create bits of reusable code (widgets) to help make your development process more object oriented.

In this second part of the series, you will learn the basics of object-oriented web page generation through the use of (X)HTML widgets. You will also see how objects implement the "HTMLRenderer" interface to explicitly define its functionality by using the "toHTML()" method.

The drawback to the "widget" approach resides mainly in the performance cost of creating many objects for rendering a web document, even if they only exist until the page has finished displaying.

They jump right in, creating the base for their widgets, the HTMLRenderer interface. From there, they show how to create the widget classes and interface them in with the HTMLRenderer (which provides a generic interface and the toHTML function for the widget subclasses).

tagged: user-defined interface php5 (x)html widget user-defined interface php5 (x)html widget

Link:

DevShed:
User-defined Interfaces in PHP 5 - Introduction to Core Concepts
Dec 21, 2005 @ 13:16:28

From DevShed today, there's a new tutorial concerning interfaces in PHP5 and how to define some of your own.

In this tutorial, I’ll introduce the use of user-defined interfaces in PHP5, covering the basics of its theory along with the implementation of different examples, aimed specifically at demonstrating its functionality in real applications.

Before we get started, a few items with be required. You should have at least a basic familiarity with the PHP5 syntax, along with an intermediate knowledge of concepts related to object-oriented programming. Therefore, having defined the objectives of the article, let’s move on to learning about user-defined interfaces in PHP5.

They still define what the interfaces are before they get started, but shortly there after they jump right in creating some other interfaces: DeSerializer, PostSaver, and MySQLCache. They tie them together in the end to make a functional example...

tagged: user-defined interface php5 core concepts user-defined interface php5 core concepts

Link:

DevShed:
User-defined Interfaces in PHP 5 - Introduction to Core Concepts
Dec 21, 2005 @ 13:16:28

From DevShed today, there's a new tutorial concerning interfaces in PHP5 and how to define some of your own.

In this tutorial, I’ll introduce the use of user-defined interfaces in PHP5, covering the basics of its theory along with the implementation of different examples, aimed specifically at demonstrating its functionality in real applications.

Before we get started, a few items with be required. You should have at least a basic familiarity with the PHP5 syntax, along with an intermediate knowledge of concepts related to object-oriented programming. Therefore, having defined the objectives of the article, let’s move on to learning about user-defined interfaces in PHP5.

They still define what the interfaces are before they get started, but shortly there after they jump right in creating some other interfaces: DeSerializer, PostSaver, and MySQLCache. They tie them together in the end to make a functional example...

tagged: user-defined interface php5 core concepts user-defined interface php5 core concepts

Link:


Trending Topics: