Prime Number Program in PHP

Prime Number :-  A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 3 is a prime number because it has no positive divisors other than 1 and 3. Prime numbers are below:- 2, 3, 5, 7, 11, 13, 17, 19 …. Here I am writing the PHP program to check whether a number is Prime or not. <?php function CheckPrime($number){ for($x=2;$x<$number;$x++){ if($number%$x == 0){ return 0; } } return 1; } $a = CheckPrime(17); if ($a==0) echo ‘This is not…

Palindrome Number Program in PHP

Palindrome Number :- A palindromic number or numeral palindrome is a number that remains the same when its digits are reversed. Like 53235,  Below are the example palindrome number:- 121 , 212 , 12321 , 16461 #Steps to Check a Palindrome Number :- Take a Number Now reverse its digit Now compare both the numbers if both are equals to each other then return “Number is Palindrome“. else return “Number is not Palindrome“ Here I am writing the PHP program to check whether a number is palindrome or not. Palindrome Number Program Without of Using PHP…

Fibonacci Series in PHP

Fibonacci series means to get next term by adding its previous two numbers. For an example:- 0 1 1 2 3 5 8 13 21 Here I am writing the PHP program to print Fibonacci Series. <?php function printFabonacciSeries($number){ $a = 0; // first number of series $b = 1; // second number of series echo ‘Fabonacci Series <br/>’; echo $a.’ ‘.$b; for($i=2;$i<$number;$i++){ $c = $a + $b; //print next number of series echo ‘ ‘.$third; $a = $b; $b = $c; } } printFabonacciSeries(9); ?> Output :- 0 1 1 2 3 5 8 13 21 Alternate Way…

How to Print Hello World Program in PHP ?

In PHP it is very easy to print “Hello World” program. “Hello World.” is the first program from where most of the beginner developers will start to write code in any language. Here is an example of how to print “Hello World!!” in PHP. Print “Hello World” Program :- In PHP we use echo to print a string and we always write the PHP code between <?php ?>  tag. Below are the example of print simple Hello World. <?php echo “Hello World!!”; ?> Output :- Hello World!! Check video :-

PHP Introduction

What is PHP:- PHP stands for PHP: Hypertext Preprocessor , it is widely – used server side scripting  language designed for web devlopment. PHP also used as a general purpose programming language. It was build up by Rasmus Lerdorf in 1994 and launched in the market in 1995. PHP is the most well known scripting language on the web. It is utilized to improve site pages. Using PHP, you can do things like a login page and login a user by creating session, check details from a form, create forums, picture galleries, surveys, and…

Top 35 PHP Interview Questions and Answers for 5 year experience

This article shows top 35 frequently asked PHP interview questions and answers for 5 years experienced PHP Developer, This list of PHP interview questions and answers will be helpful for PHP 5 experienced developer. Question #1 – How array_walk function works in PHP? It is used to update the elements/index of original array. How: in array_walk, two parameter are required.  original array An callback function, with use of we update the array.  Question #2 – What is the difference between $message and $$message? They are both variables But $message is a…

Top 35 PHP Interview Questions And Answers for 2 year experience

In this article I am sharing top 35 frequently asked PHP interview questions and answers for experience, This list of PHP interview questions and answers will be helpful for PHP experience developer. Question #1 – What is PHP? PHP is an open source server side scripting language mostly used for web applications. Its easy to learn compare to other programming language. PHP also a object oriented programming language like java, .net and c++. Question #2 – What is the difference between $message and $$message? They are both variables But $message is…

Factorial Program in PHP

image source : google images The factorial of number n is multiplying given integer with the sequence of its descending positive integers. we denoted the factorial of a number n by n! in mathematics. Here I am writing factorial program in PHP.. Example :- 5! = 5*4*3*2*1 = 120 7! = 7*6*5*4*3*2*1 = 5040   Here are writing the PHP program to find a factorial of a number. <?php function factorial($number){ $factorial = 1; for($x=$number;$x>=1;$x–){ $factorial = $factorial*$x; } return $factorial; } echo ‘factorial is=’.factorial(11); ?>   Output :- factorial…

How To Sort An Array in PHP ?

Mostly web developers face the problem of sorting an array in PHP. So to save their time here I am sharing the solution with example. Feel free to join us and you are always welcome to share your thoughts that our readers may find helpful. There are 6 functions to sort an array in PHP – #1. sort() – Sort Array in Ascending Order Below example shows sorted array in ascending order  <?php $name = array(‘sonia’,’monica’,’raj’,’yogita’); sort($name); print_r($name); ?> Output :-  Array (     [0] => monica    …

How To Start A PHP Session ?

Session is a special technique to store information of a user across the multiple pages. To begin with a new session, simply we use the PHP session_start() function. It is must to start a session in the top of every page. Session variables are set with the PHP global variable $_SESSION. Below is the simple example to start a new session. <?php // Start the sessionsession_start(); ?> <!DOCTYPE html> <html>   <body> <b> my website </b>   </body> </html> Creation & Accessing Session Data :- You can create session using $_SESSION[] php function.…