PDF Generation Using Only PHP - Part 2
by Marko Djukic |
4 comments | Tuesday, January 6, 2004
We have seen in Part 1 how PDF files are, after all, just plain text files, with specific markup syntax that describes what should happen to objects within the document, such as text and images. We shall now further examine this syntax, to allow us to create a more complete PDF document (i.e more than simple text).
PDF Generation Using Only PHP - Part 1
by Marko Djukic |
3 comments | Monday, December 22, 2003
PDF files are, after all, just plain text files with specific markup syntax that describes what should happen to objects within the document, such as text and images. It follows that, armed with some PDF logic, anyone can create a PDF file. In this tutorial you will be shown the basic features of the PDF language, to enable you to put together your own PDF document.
Advanced Form Processing with PHP and Javascript
by Mehmet Avsar |
2 comments | Wednesday, August 6, 2003
When building a web site, sooner or later you will need a form. Forms are the best way of gathering data from visitors. Your forms can be as small as a login form, or as large as a membership subscription form asking for lots of input. Obviously, the bigger the form, the more information there is to process, and the greater the challenge.
When inspecting form data, the two most important issues you have to worry about are intrusion,and gathering as much useful data as possible from your visitors. Although these issues appear to lay on just opposite sides - you want to collect lots of data, but you have to put restrictions against intruders - it is actually possible to do both. By taking a few precautions you can eliminate 95% of intruders while forcing visitors to supply the data you want.
You have tools for optimization of form’s inspection process, both client side and server side. Client side, the most important of the tools are scripting languages, particularly Javascript. Utilizing Javascript, you can limit and check form data while it’s still on the client side.
On the server side, you need nothing but PHP. But, you should be aware that some common coding mistakes in PHP may become deadly. Have a look at zend.com’s articles titled Coding Mistakes Part I, II, III for more details.
When inspecting form data, the two most important issues you have to worry about are intrusion,and gathering as much useful data as possible from your visitors. Although these issues appear to lay on just opposite sides - you want to collect lots of data, but you have to put restrictions against intruders - it is actually possible to do both. By taking a few precautions you can eliminate 95% of intruders while forcing visitors to supply the data you want.
You have tools for optimization of form’s inspection process, both client side and server side. Client side, the most important of the tools are scripting languages, particularly Javascript. Utilizing Javascript, you can limit and check form data while it’s still on the client side.
On the server side, you need nothing but PHP. But, you should be aware that some common coding mistakes in PHP may become deadly. Have a look at zend.com’s articles titled Coding Mistakes Part I, II, III for more details.
Writing Libraries in PHP
by Bill Moran |
0 comments | Thursday, July 10, 2003
The core of any programming language is its API. The API (application programming interface) is the set of available functions that allow a programmer to use the programming language. Compare an API to the language's syntax, which is the rules for stringing the various commands together so the interpreter can understand them.
Most of the documentation on PHP is focused on explaining the functioning of the various APIs PHP has available. Likewise, if you create a PHP library, most of the work involved is usually in sorting out how the API will work.
When you code a library, your primary goal is to write code that can be reused. You might be concerned with code reuse within a single application or maybe you want to publish the library for others to use. Taking the time to code your library properly results in code that often becomes more useful than you initially expected, and reduces the time it takes you to create the rest of your application. It also makes it easier to involve other programmers in your project. Obviously, a well-written library is much more likely to be useful to other programmers than one that was created carelessly.
Libraries generally take on two forms: functions and classes. PHP is a language that I generally classify as "hybrid" because it has most of the capabilities of an object-oriented language, yet the native PHP API is functional in nature. The shortcomings of PHP's object programming are not bad enough to warrant avoidance of writing class libraries. In fact, the examples and explanations in this article are based completely on class libraries, so I'll be covering some of the workarounds for those shortcomings.
Most of the documentation on PHP is focused on explaining the functioning of the various APIs PHP has available. Likewise, if you create a PHP library, most of the work involved is usually in sorting out how the API will work.
When you code a library, your primary goal is to write code that can be reused. You might be concerned with code reuse within a single application or maybe you want to publish the library for others to use. Taking the time to code your library properly results in code that often becomes more useful than you initially expected, and reduces the time it takes you to create the rest of your application. It also makes it easier to involve other programmers in your project. Obviously, a well-written library is much more likely to be useful to other programmers than one that was created carelessly.
Libraries generally take on two forms: functions and classes. PHP is a language that I generally classify as "hybrid" because it has most of the capabilities of an object-oriented language, yet the native PHP API is functional in nature. The shortcomings of PHP's object programming are not bad enough to warrant avoidance of writing class libraries. In fact, the examples and explanations in this article are based completely on class libraries, so I'll be covering some of the workarounds for those shortcomings.
JavaScript Powered PHP Debugging
by Craig Davis |
5 comments | Wednesday, June 18, 2003
Debugging in a scripting language can be problematic. There are several PHP debugging options that are growing in both functionality and popularity. However, these options generally require server access and special configuration. Most programmers revert to simply printing variables to the browser via clumsy print() or print_r() statements. Neither of these solutions is ideal. Both can interfere with page layout and the results can be interspersed throughout the page and be difficult to find. With this tutorial, you will be able to create a library that will alleviate these issues.
Smarty: A closer look
by Joe Stump |
0 comments | Tuesday, March 18, 2003
At its most basic, Smarty allows programmers to unchain themselves from the design process, a long standing dream of many. However, Smarty also has many advanced features that you may have been missing out on.
This article will demonstrate some of the more complex features in Smarty such as security features, template caching, and extending Smarty with wrapper classes. This article will show HTML designers how to extend their templates with configuration files and built-in data manipulation functions.
This article will demonstrate some of the more complex features in Smarty such as security features, template caching, and extending Smarty with wrapper classes. This article will show HTML designers how to extend their templates with configuration files and built-in data manipulation functions.
Using PHP and XSL to Transform XML into Web Content
by Benson Wong |
1 comment | Tuesday, March 4, 2003
Presenting content is one of the more time consuming and challenging tasks when building a web site. This tutorial looks at taking an XML document and dynamically transforming it into HTML using PHP and XSL. As a practical example, this tutorial is available as XML as well as the XSL stylesheet which transforms it into Zend.com's common tutorial layout.
The goal of this tutorial is to demonstrate how to use PHP and XSL to transform an XML document into HTML.
The goal of this tutorial is to demonstrate how to use PHP and XSL to transform an XML document into HTML.
SQL Query Caching
by Ori Staub |
6 comments | Wednesday, January 22, 2003
Many sites use a database backend as a data store for the site. Whether the database contains product information, category structure, articles or a guest book, some of the data is likely to be quite static and will greatly benefit from a caching system.
Such a system would cache the results of an SQL query into a file stored on the system and hence improve the response time by avoiding the need to make a database connection, forming the query, executing it and retrieving the results.
On systems where the database does not reside on the same machine as the web server and requires a remote connection (TCP or similar), or where large amounts of data are retrieved from the database, you stand to gain even more in terms of response times and resources used.
Such a system would cache the results of an SQL query into a file stored on the system and hence improve the response time by avoiding the need to make a database connection, forming the query, executing it and retrieving the results.
On systems where the database does not reside on the same machine as the web server and requires a remote connection (TCP or similar), or where large amounts of data are retrieved from the database, you stand to gain even more in terms of response times and resources used.
Error Handling: Stepping beyond True/False Results
by Justin Eckhouse |
0 comments | Tuesday, December 31, 2002
Proper error handling is a struggle for most software engineers, myself included. There is no fun in error handling, no logic puzzles to solve. Most of us don’t add any kind of error handling to our code until we run into a problem.
When Sun developers designed Java and created their exceptions, they understood the fundamental laziness of programmers. Therefore, in Java, you must handle a method that might cause an exception; if you don't, your code will not compile. PHP offers no such handholding, and therefore it is up to you, the programmer to take preemptive action.
This article will give you the capabilities to handle errors in an elegant manner without diverging too much from your lazy ways. We will look at how to handle PHP script errors, as well as passing around your own errors with the PEAR module: PEAR_Error.
When Sun developers designed Java and created their exceptions, they understood the fundamental laziness of programmers. Therefore, in Java, you must handle a method that might cause an exception; if you don't, your code will not compile. PHP offers no such handholding, and therefore it is up to you, the programmer to take preemptive action.
This article will give you the capabilities to handle errors in an elegant manner without diverging too much from your lazy ways. We will look at how to handle PHP script errors, as well as passing around your own errors with the PEAR module: PEAR_Error.
Googlifying Search Results
by Darrell Brogdon |
0 comments | Tuesday, December 10, 2002
Most people are familiar with doing searches on Google, and how Google formats search results. First, the search criteria text appears in a bold font. Second, the text of the search results ends with an ellipsis (...) to let the user know that there is more information where that came from. These little UI features make it easy for readers to find what they are looking for.
