Category Archives: PHP

WordPress Helper: PHP Snippets for Header

Below are snippets for making header in WordPress. It is more useful. Just you need to copy snippets and paste at appropriate place. Title of the site: <?php bloginfo(‘name’); ?> Title of specific post or page: <?php wp_title(); ?> The style.css file’s theme location: <?php bloginfo(‘stylesheet_url’); ?> Pingback URL for the site: <?php bloginfo(‘pingback_url’); ?> […]

WordPress bloginfo()

I have started learning WordPress and gather some required information about it. Here I am talking about WordPress bloginfo() function. It returns information about your site. Bloginfo() is most useful function in wordpress. Using bloginfo() function you can get information which you have given in User Profile and General Options (settings -> general) from the […]

switch development to production server automatically

In order to define database credential most of time we make one page like db.php and define all DB variables as follows for development and production server: define(‘HOSTNAME’,’localhost’); define(‘USERNAME’,’root’); define(‘PASSWORD’,”); define(‘DATABASE’,’testdb’); //define(‘HOSTNAME’,’hostname’); //define(‘USERNAME’,’username’); //define(‘PASSWORD’,’password’); //define(‘DATABASE’,’testdb’); After moving on production server DB variables as like: //define(‘HOSTNAME’,’localhost’); //define(‘USERNAME’,’root’); //define(‘PASSWORD’,”); //define(‘DATABASE’,’testdb’); define(‘HOSTNAME’,’hostname’); define(‘USERNAME’,’username’); define(‘PASSWORD’,’password’); define(‘DATABASE’,’testdb’); I have seen […]

CODING TIPS FOR PERFORMANCE IMPROVEMENT

In this post I cover most performance improvement tips related JavaScript, CSS and PHP. While working with small web application its OK to ignore these tips but whenever you are going to dealing with large web application which will have so many user base and may increase database day by day then you should have to take […]

Reset MD5 password using phpMyAdmin?

As you know MD5 (Message-Digest algorithm 5) is one way encryption method. In order to reset MD5 password you have to run database query. Here I have got one direct solution for resetting MD5 password using phpMyAdmin GUI. Follow below steps to reset MD5 Password. Open phpMyAdmin. Open record in edit format which you want […]

get rid of write array name each time in PHP

In today’s era noone has time and every person wants to save their time. As a being a good programmer I also have to reduce my coding time so I can go for other stuff. If you are PHP developer then you know you need to write array name each time like $_POST, $_GET, $_SESSION…. […]

Some Most Useful PHP string functions

In today’s era PHP is more popular web based scripting language. If you are PHP developer then below string function you may need in your programming. trim Strip whitespace from the beginning and end of a string Syntax : string trim ( string $string [, string $charlist ] ) Return : Terminated String This function returns a string with whitespace stripped from the […]

How to get first and last day of month in PHP?

In order to run report with date range, most of people want to set default date range of current month. There may be two type of requirement in this type of case. Fromdate should be first day of month and Todate should be today date. Fromdate should be first day of month and Todate should […]

mysql_num_rows() VS mysql_affected_rows()

Today I need to display record set like how many rows fetched or affected by query. There are two different function in PHP to get fetched or affected rows information and it is mysql_num_rows() and mysql_affected_rows(). What is the different between mysql_num_rows() and mysql_affected_rows()? The mysql_num_rows() function is used with select statements whereas mysql_affected_rows() function […]