Articles for PHP

PHP fluent interface

In: PHP

23 Nov 2011

Tweet PHP fluent interfaces have been around for quite some time. They are often used just for chaining methods of an object so that we get nice readable code. Good fluent interface takes a while to build, and will take some planning to make object methods work seamlessly. However, if you still haven’t experienced the [...]

Tweet Have you ever wondered if you could let user see his website visits on his own admin page without having to leave backend of his system? I have… Actually – the CMS I made for my clients (written in Zend Framework) has this option for quite some time, and users love it. So – [...]

Tweet Get number of Twitter followers using this PHP snippet is easy. Once you get all the data from Twitter, you just have to isolate followers_count. Besides followers count, you can extract following data as well: id name screen_name location description profile_image_url url friends_count created_at lang Now, finally, to get number of Twitter followers, use [...]

PHP contact form

In: PHP

16 Dec 2010

So, almost every website needs contact form – is it a real contact form or just a feedback from your users. We need to make a contact form as easy to deal with as possible.

PHP download counter

In: PHP

4 Nov 2010

Tweet This is an example how PHP download counter could be made. This is just a basic but still functional example. So, in order to make a download counter we shall need three scripts: download_file.php download_count.php show_download_number.php First part of our PHP download counter script will be replacing actual file that should be downloaded, and [...]

Tweet Script authors: Drasko Gomboc and Sankovic Marko. When running automated backup it is a good practice to save exact time when you made backup in your file name. This snippet shows you how to automatically add date and time before extension in your file name. 1 2 3 $filepath = ‘/backup/folder/drasko_gomboc-and-sankovic_marko.txt’; $new_filepath = preg_replace("/(.[^.]*)$/", [...]

Tweet So, let’s say you are about to launch your new website. You have written it and tested in localhost, and it is time to go live! Only… not in the public yet. You want to adjust some more things, and check if your website is working correctly, and you don’t want users to see [...]

Similar text PHP

In: PHP

29 Sep 2010

Tweet With PHP function similar_text(), you can offer your users a Google like “Did you mean” suggestion to a misspelled word. All you need is a word by word comparison using a PHP function similar_text. See and use snippet below in order to find most similar word to the one you choose. 1 2 3 [...]

PHP Newsletter script

In: PHP

24 Sep 2010

Tweet Suppose you’ve just finished designing your personal newsletter and you wish to test it. Here’s a small snippet that you might find handy. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 $query = ‘SELECT id, email FROM users’; $result = mysql_query($query);   while [...]

Tweet Facebook sharing is just getting more and more popular, and it is good to let your visitors share content on your blog using their Facebook profile. Facebook share button is easy to use – as copying this snippet and pasting it into your website. This way you can customize you Facebook share button by [...]

Make Magento Checkout Awesome