PHP

Blocking email harvesters

August 25, 2011

Email spammers often use programs, known as email harvesters that scan pages on the Internet for email addresses to collect and send unsolicited email. If your email address is publicly available through your WordPress installation, it may be vulnerable to these kinds of programs. Below are a few simple ways you can use to protect [...]

Read the full article →

Exception Handling in PHP

August 21, 2011

Exceptions are the pieces of code which are used to alter the normal flow of the code if a certain error occurs. The concept of exceptions is being used in almost all high level languages. Whenever an exception occurs, the current code state is saved and code execution is switched to a predefined (custom) exception [...]

Read the full article →

Generating XML file using PHP and ASP

August 6, 2011

XML files, as we know by now, are plain text files just like the HTML files. Hence, just like HTML, XML can also be easily stored and generated by a standard web server. For example, consider the following piece of code: <?xml version=”1.0″ encoding=”ISO-8859-1″?> <note> <from>John</from> <to>Tove</to> <message>Remember me this weekend</message> </note> The above code [...]

Read the full article →

Filter PHP variables using filter_var function

August 2, 2011

Filters in PHP are highly useful to filter and validate data coming from non reliable and insecure sources. Additionally, the PHP filter extension is designed to make data filtering easier and quicker. Almost all web applications depend on external input. Usually this comes from a user or another application (like a web service). Implementation of [...]

Read the full article →

Important Math Functions in PHP

July 28, 2011

The importance of predefined mathematical functions for web programming as well as software design can not be overemphasized. PHP provides some very simple yet powerful math functions to undertake this task. The math functions in PHP can handle values within the range of integer and float types. Good thing is, the math functions are part [...]

Read the full article →

Creating Object Iterators in PHP

July 19, 2011

Items can be iterated with the help of arrays in PHP but when arrays are not available, there is alternate and even more efficient method to undertake the same task. This is particularly useful while reading records from a database or lines of text read from a file. In this tutorial, we would create a [...]

Read the full article →

Smarty! A PHP Based Template Engine

December 29, 2010

Smarty is a well known template engine for PHP developments. Smarty’s main concern is to separate the core PHP code from the design layout and files, including CSS style sheets, actual HTML templates etc. Smarty uses its own tags structure in the HTML pages and optimize the overall website speed and performance by utilizing its [...]

Read the full article →

Compress your CSS with PHP

July 20, 2010

It is possible to compress your CSS style sheet with PHP. Here is how you can do that. Create a CSS file with .php extension. For example; stylesheet.php <?php ob_start (“ob_gzhandler”); header(“Content-type: text/css; charset: UTF-8″); header(“Cache-Control: must-revalidate”); $offset = 60 * 60 ; $ExpStr = “Expires: ” . gmdate(“D, d M Y H:i:s”, time() + [...]

Read the full article →

PHP – Send HTML email tutorial

July 15, 2010

PHP mail is a simple mail function for PHP. It is used to send emails right from your web pages. It also allows you to send plain text and HTML based emails. Here are is a simple tutorial on how to send HTML emails from your website. First step is to set parameters for recipient [...]

Read the full article →