Both cookies and sessions are available in any type of programming language like PHP, and both accomplish much the same task of storing data across pages on your site. However, there are differences between the two that will make each favourable in their own circumstance.
Category » PHP
using PHP code into WordPress widget
Sometime we need to insert PHP code into Wordpress text widget but by default, Wordpress ignore PHP code into widget. People use plugin for getting this but we can achieve it by using below given code into theme’s function.php.
How to check a value exists in an array
How to check a value exists in an array is a general requirement when using array. We can do it by iterating through the array one by one and checking that the searched value exist or not. But now a days, everybody expects a short method means using built in functions in the language.
How to Redirect URL
There are several ways to redirect a user from one URL to another. There might be several reasons to do this. I am describing different ways to redirect a URL or page quickly and seamlessly including redirect URL using JavaScript, use a meta tag, redirect using an htaccess file, redirection using PHP and finally redirect URL in WordPress.
PHP Interview Questions – I
In this article on PHP Interview Questions, I have compiled a list of fundamental PHP interview questions and answers that were asked in a real interview for a PHP web developer position. Every PHP web developer should know these questions/answer of PHP. So, either you are preparing for any interview in PHP development or are a web developer, you should go through the following list of interview questions in PHP. These PHP questions are mix of basic PHP questions to advance questions that expert PHP engineers know.
Merge two arrays in PHP
The array_merge() function merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array.
<?php $A1=array("apple","papaya"); $A2=array("banana","grapes"); print_r(array_merge($A1,$A2)); ?> Output would be : Array ( [0] => apple[1] => papaya[2] => banana [3] => grapes )
Increase the PHP Script execution time
set_time_limit : set/increase the PHP Script maximum execution time
By default, PHP has a set of seconds limit to execute the script, if some script reach to run then some fatal error occurs.