Home arrow PHP arrow Working with the Tidy Library in PHP 5

Working with the Tidy Library in PHP 5

As a PHP developer, you've probably developed database-driven applications that deliver their contents in (X)HTML format to the end user. If so, you know that when you work directly with hard-coded (X)HTML files, you risk forgetting to close tags and DTD headers, making the process annoying and time-consuming. Keep reading; help is on the way.

TABLE OF CONTENTS:
  1. Working with the Tidy Library in PHP 5
  2. Parsing (X)HTML strings
  3. Implementing the tidy_clean_repair() function
  4. Using the tidy_parse_file() and tidy_repair_file() functions
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
June 26, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

As you know, hand-coding (X)HTML files certainly forces your PHP applications to have a clean and tight presentation layer, but actually giving your code this quality comes at a cost. You'll need to verify that all those files have been created in the correct format. Is there any way to make this process as painless as possible?

Of course there is! If you've ever worked with code editors like Home Site and Dreamweaver MX, to name just two, then you'll recall that all of them incorporate the popular Tidy application as part of their arsenal of code-cleaning tools. It's extremely useful for correcting rapidly any errors that have occurred while coding (X)HTML files.

However, the real good news about Tidy is that you can take advantage of its neat features by accessing it from your PHP files, since this excellent code-cleaning package is now available as an external library in PHP 5. This means that you can correct any source (X)HTML files very efficiently and with minor hassles.

Thus, now that you know that the Tidy (X)HTML formatting/correcting application can be called directly from your own PHP 5 scripts, over the course of this series, which is comprised of three friendly tutorials, I'm going to walk you through using the bunch of useful functions included with this library. Naturally I'll accompany the corresponding theory with a decent number of code samples, so you can learn quickly how to make this PHP extension work for you in a very short time.

Now, it's time to get rid of the preliminaries and start learning how to work with the Tidy library and PHP 5. Let's go!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap

Dev Shed Tutorial Topics: