Category Archives: Validation

Mastering the array_diff Function in PHP: A Comprehensive Guide

PHP is a popular programming language for web development because it is strong and adaptable. Its broad feature set of built-in functions is just one of the numerous factors contributing to its popularity. array_diff is one of these functions that is especially helpful for manipulating arrays. We will examine the PHP array_diff function, comprehend its… Read More »

What is the difference between a session and cookies?

Difference between cookies and session is : Cookies stores the information on client browser and session stores the information on server. session and cookies are used to store the information.

Validate Email in PHP

Use this function to validate email in PHP. Pass your email in this function by calling it.if  it returns false then email is not valid else valid. function checkEmail($email_address = null){ if(preg_match("/^[a-zA-Z]*w+(.w+)*@w+(.[0-9a-zA-Z]+)*.[a-zA-Z]{2,4}$/", $email_address) === 0){ return false; } else{ return true; } }function checkEmail($email_address = null){ if(preg_match("/^[a-zA-Z]*w+(.w+)*@w+(.[0-9a-zA-Z]+)*.[a-zA-Z]{2,4}$/", $email_address) === 0){ return false; } else{ return… Read More »

Validate URL in PHP

To validate url at server side use this function. In this function $variable defines the your string which you want to validate. <?php $reg_exp = /(http?://)?([da-z.-]+).([a-z.]{2,6})([/w ?=.-]*)*/?$/ ereg($reg_exp,$variable); ?><?php $reg_exp = /(http?://)?([da-z.-]+).([a-z.]{2,6})([/w ?=.-]*)*/?$/ ereg($reg_exp,$variable); ?>