What is the difference between a session and cookies in PHP?

Session V/S Cookies Cookie is an array of data stored by the browser on client location and sent to the server with every request. It store limited amount of data about 4kb(i.e.: 4096 bytes). It is…

Write a example code showing the nested ternary conditional operator in PHP?

A example code showing the nested ternary conditional operator in PHP. <?php $background_color = ($num == 0 ? 'blue' : ($num > 0 ? 'green' : 'red')); ?> Here we are assigning different strings to…

Convert Object To Array in PHP

For converting an object to an array is a small thing which can be achieved by  a single line of code. For this purpose we need to use typecasting. Typecasting is a way to use/convert…

Converting array of objects to array in php

Array of objects look like this: Array ( [0] => stdClass Object ( [id] => 1 [name] => Ram [roll] => 12 ) [1] => stdClass Object ( [id] => 2 [name] => Shyam [roll]…

Sort an array of array by date in PHP

Here a situation in which we have to sort an array of array by date. Array of array is a multi dimensional array in which an array holding multiple array as data. the array is…

Export and import database using SSH

Export and import database using SSH Using SSH can be a good practice to manage the files and databases on your account. It is most important to use in following circumstance Servers without a control…

How to find the length of a string in PHP?

Length of a string There is a string function called strlen() which is used to find the length of a string. It accept a string returns the length of the given string.  strlen(string);   Let's…

How will you concatenate two strings in PHP?

Concatenate two strings For concatenate two strings together, we use dot (.) operator.   <?php $str1="Hello World! "; $str2="Welcome to StudyZone4U.com"; echo $str1 . " " . $str2; ?> // output This will produce following result…

How can we remove duplicate value from an array in php?

Duplicate value can remove from an array by using array_unique function. If two or more array values are the same, the first appearance will be kept and the other will be removed. It takes an…

What is access specifiers in php?

Access specifiers An access specifier is a code element which is used to determine which part of the program is allowed to access a particular variable or other information.   There are three types of…

What is php.ini and .htaccess file?

php.ini and .htaccess file Both php.ini and .htaccess file is configuration file. php.ini: It is a configuration file for php setting. It is a special file by which you can make changes in PHP settings.…

what are php magic fuction?

magic fuction In PHP all functions start with __ names are magical functions. Magical functions always lives in a PHP class.The definition of magical function are defined by programmer itself. Here are list of magic…

what is list in php?

List  List is a language construct and is similar to an array. It is used to assign a list of variables in one operation. If you are using PHP 5, then the list values start…

what is Cross-site scripting?

Cross-site scripting (XSS) Cross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications. XSS enables attackers to inject client-side script into web pages viewed by other users. A cross-site scripting…

What is the difference between explode() and implode() function?

 PHP | implode() and explode() function implode() function is use to convert an array into a string where as explode() function is used to convert an string into an array   implode() The implode() function…

How we can remove html tags from string?

Remove html tags from string The strip_tags() function is use to remove any HTML, XML, and PHP tags from a string.   <?php echo strip_tags("Hello <b><i>world!</i></b>","<b>"); // Output will be Hello world! ?>  

How we can find last insert id in table?

By using mysql function mysqli_insert_id() we can retrive the last inserted id in database table.

How to upload file in PHP?

By using move_uploaded_file() function we can upload file in PHP.The move_uploaded_file() function moves an uploaded file to a new location. This function returns TRUE on success, or FALSE on failure. move_uploaded_file(file,newloc)   <?php $target_dir =…

What is recursion in PHP?

Recursion  PHP also supports recursive function call like C/C++. In such case, a function calls itself within function.   Note: Recursion must be incorporated carefully, since it can lead to an infinite loop if no…