XPath Queries 1
One of the most powerful parts of the DOM extension, is its integration with XPath in fact, DomXpath is far more powerful than the SimpleXML equivalent dom new DomDocument dom- gt load libra ry.xml result foreach result as book echo book- gt data This example seems quite complex, but in actuality it shows just how flexible the DOM XPath functionality can be. First, we instantiate a DomXpath object, passing in our DomDocument object so that the former will know what to work on. Next, we register...
The Factory Pattern
The Factory pattern is used in scenarios where you have a generic class the factory that provides the facilities for creating instances of one or more separate specialized classes that handle the same task in different ways. A good situation in which the Factory pattern provides an excellent solution is the management of multiple storage mechanisms for a given task. For example, consider configuration storage, which could be provided by data stores like INI files, databases or XML files...
Lazy Loading
Prior to PHP 5, instantiating an undefined class, or using one of its methods in a static way would cause a fatal error. This meant that you needed to include all of the class files that you might need, rather than loading them as they were needed just so that you wouldn't forget one or come up with complicated file inclusion mechanisms to reduce the needless processing of external files. To solve this problem, PHP 5 features an autoload facility that makes it possible to implement lazy...
CrossSite Request Forgeries
A cross-site request forgery CSRF is an attack that attempts to cause a victim to unknowingly send arbitrary HTTP requests, usually to URLs requiring privileged access and using the existing session of the victim to determine access. The HTTP request then causes the victim to execute a particular action based on his or her level of privilege, such as making a purchase or modifying or removing information. Whereas an XSS attack exploits the user's trust in an application, a forged request...
Perlcompatible Regular Expressions
Perl Compatible Regular Expressions normally abbreviated as PCRE offer a very powerful string-matching and replacement mechanism that far surpasses anything we have examined so far. Regular expressions are often thought of as very complex and they can be at times. However, properly used they are relatively simple to understand and fairly easy to use. Given their complexity, of course, they are also much more computationally intensive than the simple search-and-replace functions we examined ear...