Saturday, April 30, 2011

PHP Simple HTML DOM Parser - an Intoduction

PHP Simple HTML DOM Parser, is one of the easiest DOM manipulation script written in PHP5+. Being Open source, it is free to use under the MIT License. Supporting invalid HTML, this parser is better then other PHP scripts that use complicated regexes to extract information from web pages. It helps to find tags on an HTML page with selectors just like jQuery.

Some of the Usage examples are:

Friday, April 29, 2011

Cleaning and Validating user input with htmLawed

htmLawed is a highly customizable single-file PHP script to make text secure, standard and admin policy-compliant for use in the body of HTML 4, XHTML 1 or 1.1, or generic XML documents. It is thus a configurable input (X)HTML filter, processor, purifier, sanitizer, beautifier, etc., and an alternative to the HTMLTidy application.

The lawing in of input text is needed to ensure that HTML code in the text is standard-compliant, does not introduce security vulnerabilities, and does not break the aesthetics, design or layout of web-pages. htmLawed tries to do this by, for example, making HTML well-formed with balanced and properly nested tags, neutralizing code that may be used for cross-site scripting (XSS) attacks, and allowing only specified HTML elements/tags and attributes

Thursday, April 28, 2011

PHP CLI script and Command line arguments

One of the advantages of  PHP is that, it can be run from the command line like a c program. Sometimes scripts are made to run behind the browser to give faster response to the user, and some time to run the bulky operations. (video conversion, cron, backups).

There are to ways to get the arguments in the script, while running it from command line:

Monday, April 25, 2011

File Upload via CURL in PHP

Most of us must have used CURL in PHP, But have you uploaded file using it. If not I must say it is very easy .

Here is the simplest way to upload the file via CURL.

Sunday, April 24, 2011

Nice silde show about the PHP 5 Magic Methods

I was looking to my bookmarks and wow found this very nice slides show about the PHP 5 Magic function. I think it is worth sharing, and is quite help full for the PHP OOPs beginners

Search engine friendly re-direct with php headers

Many times we need to re-direct a page to another page, due to lots of reasons like:
  1. You changed your URL patterns to new patterns.
  2. The Old links are dead.
  3. You simply moved your site to new domain,
And might be lots of other issues... But have you ever thought will search engine follow these links...
Here are simple PHP headers to re-direct the page to new location.

Thursday, April 21, 2011

A Wonderful Image upload and manipulation class "class.upload.php"

Just found a great Image uploading and manipulation class written in PHP, by Verot.net

Description as provided by the supplier::
"The perfect script to generate thumbnails or create a photo gallery! It can convert, resize and work on uploaded images in many ways, apply effects, add labels, watermarks and reflections and other image editing features. You can use it for files uploaded through an HTML form, a Flash uploader, or on local files. It uses the GD library."

You can Download it from: http://www.verot.net/php_class_upload.htm