PHP, JSON and JavaScript usage

Posted on July 17th, 2008 at 7:16 pm

Today i want to introduce you to jSON (JavaScript Object Notation), in short, it is a simple format designed to exchange data between different programming languages. I will show you how to create JavaScript object, convert it to JSON string, and send to PHP script, which will decode jSON string to readable format (for PHP). But that’s not all, PHP script will create it’s own data object encode it to jSON string and send it back. All communication between JavaScript and PHP will be done thru AJAX. Read the rest of this entry »

Clean input variable PHP

Posted on June 29th, 2008 at 4:43 pm

Some time ago i wrote a post about query string and i think i pretty well covered that topic, however i didn’t mentioned one thing … cleaning input variables. In fact it is much more important to know how to clean $_POST and $_GET arrays then know how to handle query string, because variables sent by user are the only way to hack your script, it is that simple, if you take care of input variables then your script is 100% safe.

Read the rest of this entry »

Using PHP cURL to read RSS feed XML

Posted on June 19th, 2008 at 5:17 pm

I very rearly, use feeds, i prefer to go to my favourite website and see what is going on instead of downloading their content to my computer with some RSS reader. However the fact is feeds are getting popular and people are searching for a ways to access and easily automatically parse those feeds with PHP, and because RSS and ATOM are nothing more then XML documents then i have for you really simple way of handling those feeds which i want to share with you (thru my blog as well thru my blog feeds :) ). Read the rest of this entry »

PHP Query String

Posted on June 12th, 2008 at 7:19 am

Query string plays important role in building web applications, especially if you want to make nice urls without question mark and many key, value pairs, actually it is not so easy to design application with nice urls however it is always worth doing so, because it not only looks very proffessional, such URLs are search engine friendly, which means that they will get indexed faster but also it happens that search engines have problems with indexing pages with more then 3 key=value pairs in query string.

Read the rest of this entry »

PHP DateTime and DateTimeZone Tutorial

Posted on June 3rd, 2008 at 6:23 am

With each new version PHP is getting more and more object oriented. In version 5.x we get two useful classes for date and time handling. Many programmers are still using outdated methods which are available in PHP mainly for compatibility reasons, so i want to introduce you to DateTime and DateTimeZone objects. Read the rest of this entry »

PHP namespaces

Posted on May 27th, 2008 at 7:00 am

Recently while reading some other web development blog, i have found info about PHP namespaces, for those who do not know what is a namespace here is a short explanation: Basically every language is a namespace, and it doesn’t matter whatever it is a programming language, formal language of forign language. When it comes to programming languages, some of them has got a set of namespaces and importing or including one of them allows to use a set of new classes and objects.

Read the rest of this entry »

Is your HTML code Tidy?

Posted on January 3rd, 2008 at 9:47 am

When creating huge Internet applications it sometimes hard to keep your HTML code in good shape, especially if users are allowed to submit their articles or posts, there is always possibility of none closed tag or any similar small problem, with big consequences.

Basically there are two solutions for this problem, write complex scripts to check syntax of submitted text, or configure Tidy extension, write few lines of code and never think about it again. In my opinion second solution sounds more tempting, and in this article I want to show you how it is done.

But, before we start. What is Tidy extension? According to PHP manual: Tidy is a binding for the Tidy HTML clean and repair utility which allows you to clean and otherwise manipulate HTML documents.

Read the rest of this entry »

How to create WordPress Plugin from a scratch

Posted on August 9th, 2007 at 7:00 am

WordPress blogs are getting more popular then ever, there are literally hundreds of new weblogs popping up everyday. However WordPress is not a new software, so I think it is about time to learn how to create decent plugins for it, and once you learn how to write plugins you will discover that this is not only fun but can be very profitable as well.

Read the rest of this entry »

Optimizing PHP scripts

Posted on July 13th, 2007 at 8:00 am

This post is mainly for new programmers and web developers, but advanced programmers also can make use of it. While browsing forums i often see programmers asking questions about their scripts why doesn’t they work mainly, don’t get me wrong i have nothing against asking questions, but i noticed something else what concerned me, most of newbies do not optimize their scripts, as long as they do not have much visits on their websites it is ok, they can get away with it.

Read the rest of this entry »

Creating watermarks with PHP and GD Library

Posted on July 11th, 2007 at 7:26 am

The last post i wrote was about getting started with GD library, today i want to show you practical use of this wonderful library. I want to protect all images on my server, so i need to create watermarks for all my images, but let’s pretend i want to sell this images at the same time so there cannot be any watermarks on it. There are two solutions to this problem: create images with and without watermarks or use GD library and create watermarks on the fly. Obviously we will take advantage of the second method because it is more professional and requires less work in the end.

Read the rest of this entry »