Category Archives: php

Filters in Yii

Yii FiltersFilter is a piece of code that is configured to be executed before and/or after a controller action executes. For example, an access control filter may be executed to ensure that the user is authenticated before executing the requested action; a performance filter

may be used to measure the time spent executing the action.
An action can have multiple filters. The filters are executed in the order that they appear in the filter list. A filter can prevent the execution of the action and the rest of the unexecuted filters.
There are two types of filter

Continue reading Filters in Yii

How to read files in PHP

There are many options are available when it comes to file processing with PHP. Each option has its own importance. We will discuss some of the functions related to file processing, such as fopen, fclose, feof, file, file_get_contents etc. We will also discuss, when we should use which function, because it always depends on the goal of parsing the file.

Continue reading How to read files in PHP

2 most common php url functions for daily use

Seldom every php developer need some php url functions to work with , usually while parsing a web portal or finding the links url functions come very handy.

Here are URL based functionalities a developer may need .

1) Get the url of the portal:-


echo $_SERVER('HTTP_HOST');

2) Parse the url for extracting all components:-


$url_demo = 'http://user:pass@host/path?arg=val';

print_r(parse_url($url_demo));

Hope these handy code snippets would help you to save time for URL formatting in PHP.

Open Dada PHP Class – Ringtone Affiliate API

Recently i needed to make a ringtone download website for a friend and we researched on web for a good affiliate with a decent API to make things easier for content download and integration on website.

We ended choosing OpenDada.com which is a affiliate website for dada.net , Dada.net is a premier provider for providing ringtones and other mobile content.

The API documentation for OpenDada can be found at API docs page .

There are four methods that are defined in the class, Namely they are:-

search_ringtone(“ARTIST NAME”);

top10();

display_single_ringtone(“ARTIST NAME”, “SONG TITLE”);

get_genre(“GENRE”);

All methods are explained in the example.php file and can be found here.

Todo List:-

1) Add functionality to get more than 10 ringtones.
2) Put the

It’s Skin. Need class in phpclasses.org
3) Add option of inserting partner id

Will update the class with more functionality sooner.

5 important tips for Debugging PHP Code

Debugging PHP code is a  nightmare for all Php developers and these are the times when they miss the thread functionality like java in php, However some simple php debugging techniques can help y0u to code faster and thus save very valuable coding time.

These all debugging techniques are based on my experience and i would love to know what more techniques php programmers use for debugging there php code !, Please comment below and share with community if you know a secret weapon in php code debugging.

So , My 5 debugging tips are (in no particular order):-
Continue reading 5 important tips for Debugging PHP Code

Creating a cache file in php for API requests

Web 2.0 was all about mashups and data api’s !, Some of the popular ones are google search api , twitter api etc.

All API’s have some rate-limiting , For example Twitter API has a rate limit of 150 requests per hour ! , Yahoo API and Google API’s have a daily limit on their requests.

The ultimate method of getting over this API request limit is to make a cache method which stores all data that is coming from API , Which you can refresh hourly, weekly or daily !
Continue reading Creating a cache file in php for API requests

Database basics: Connect to a Mysql Database

This tutorial is part of the Tutorial Series Database basics !, Let us learn and try to understand how connecting a mysql database works in PHP

Before learning how to connect to a database we should know how to create a database , For creating a database there are several methods that we can use , Some of the most common methods are Phpmyadmin , Cpanel Mysql database panel and Command line.

Let’s learn the method of connecting to the database, For this create a file called db_operations.php and put these contents there



Continue reading Database basics: Connect to a Mysql Database

How to create a Simple Php Contact form

Here I am going to discuss a most common and necessary component which everyone requires for their blog or website, which is a contact-us form. Below you will find the code of a simple contact form. Also, I will discuss how to create the form and handle its submission. Generally We require that when someone is filling the form, its information will be either stored in a database or will be mailed to a given email address. In this post, we will only discuss the email part. You are welcome to modify and store the information in database with very small tweaks.

Let’s start..!! We need files, one to display the form and other one to capture its submission:

  • contact.php : this will contain the html code for the contact form.
  • process.php : this file will have necessary php cods for handling the above contact form.

//

Continue reading How to create a Simple Php Contact form