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

Tuesday, April 19, 2011

Image resize and thubnail with PHP - functions

As websites are getting more and more feature enabled and fully loaded with the multimedia, the need of managing the media like, Music, Images, Videos is increasing day by day. One of the most used media is Images. Image gallerias, Slideshows, light-boxes are common every site. Each of this task is going to need the image resize or creating smaller thumbnails to display. So here is a small function with which you can easily create thumbnails from the image. The following function can resize and crop the image dimensionally or just creating a perfect square.

Monday, April 18, 2011

The difference between the "isset", "empty" and "is_null"

Most the times I have noticed the beginners are confused in testing the variable, whether it contains some data or not. Most of the time these checks fail as the wrong function is being used to assert the correct value. While it is important to be checking values, it is equally important to understand the difference between the different methods of checking and testing values for empty, null, or if they are set.

The following difference chart between "isset", "empty" and "is_null" will be quite helpful for everyone.

Sunday, April 17, 2011

PHP Tutorial for Beginners - by Webmonkey

Just found a great PHP tutorial for Beginners at Webmonkey. It is indeed a very well written and explained tutorial for the beginners who are completely new to PHP. It covers almost everything Basic syntax, Variables, HTML Forms, Arrays, Loops, Functions and lot more.

Read it here

Enjoy reading it. Thanks.

PHP type comparison tables

It is sometimes hard to determine the type of the given variable while comparing it. So this table might help lot in such cases.

Saturday, April 16, 2011

10 Best PHP Coding Style Practices

One the major problem for the beginners is the STYLE OF CODING, as it was for me as well. For some of the first few months I was stuck with the standards of different Frameworks and was following them and extracting the best of their styles. But short after I felt that, although they all are very different from each other but they have something in common, their Coding patterns. 

Lets Start.
  1. First of all Choose your favorite IDE. There are lots of PHP IDE in the markte, like NetBeans, Eclipse, PHPEdit, and lots more, Just Google :). As per my favorite I user NetBeans.

Wednesday, April 13, 2011

What is this blog for

Wow.. Finally writing for the blog. Sharing PHP, name itself describes the purpose of the blog. Well this blog is started to share the PHP resources I know, and I'll found on web.

It happened to me so many time, that I want to find something about the some basic or advance stuff about PHP, what I do is just GOOGLE, but I end up lots of sites, around 30 mins of wasted time, and reading not what I exactly wanted but lots of other stuff. And I am sure most of the beginner do the same thing. So me and my Pals decided to launch a site for the beginners as well as advance users to make a one stop search for the PHP programmers.

So as result this Blog is started, Sharing PHP. Its just a another blog, hosted at blogspot currently, but let me make clear that we have lot to come and much bigger plans to share ahead. So guys Keep on looking back and enjoy the Blog.

Thanks.. and WELCOME TO THE NEW WORLD. :)