Easy To Learning
  • Login
  • Sign Up
  • Q&A
  • Home
  • Php Tutorial
  • MySql Tutorial
  • Object-Oriented Programming
  • Java Tutorial
  • HTML Tutorial
  • React JS Tutorials
  • Free Projects
  • Blogs & Articles
  • Others
    • About Us
    • Contact Us
Online Technical Tutorial
Easy To Learning

Education Needs Complete Solution

Online Ask Question Question And Answer
  1. Home
  2. Blog & Articles
  3. PHP Interview Questions And Answers
Php Tutorials

PHP Interview Questions And Answers

By admin
Jan 04, 2020
3 min read

Quick Summary: PHP Interview Questions And Answers: PHP interview question for fresher and experience student or employee

PHP Interview Questions And Answers

PHP Interview Questions And Answers

What Is PHP

PHP is a server-side scripting language, its use to create dynamic web pages, PHP syntax like C & Perl.

What Is the final class and final method

Final Class: The final class means that class can not be extended, it's introduced in PHP5.

Final Method: final method can not be overridden

What is unlink and unset

Unlink: The unlink function is dedicated for file system handling. Its use to delete the file given as entry.

Unset: The unset function is dedicated to variable management. it will make variable undefined

Type of cast variable in PHP

(int),(integer): cast to integer
(bool),(boolean): cast to boolean
(float),(double),(real): cast to float
(string): cast to string
(array): cast to array
(object): cast to abject

 

How to get number of parameters passed in function

Answer:   func_num_atgs()


How to find nth highest salary

select salary from employee order by salary desc limit 1,(n-1)


How to remove a duplicate record from the table 

select u1.name,u2.email from users as u1 inner join (select email from users group by email Having count(id)>1) as u2 on u1.email=u2.email


What are traits

Traits are a mechanism that allows you to create reusable code in PHP where multiple inheritances is not supported. To create traits we use keyword traits

trait users{
    function getUserType(){}
    function getUserRes(){}
    function getUserDelete(){}
}

class Employee extends Base{
    use users;
}


How to Create a Reverse Pattern 

*****
****
***
**
*
<?php
for($i=0; $i<=5; $i++){
    for($j=5-$i; $j>=1; $j--){
        echo "* &nbsp;";
    }
    echo "<br>";
}
?>

How to create a pattern 

*
**
***
****
*****
for($i=0; $i<=5; $i++){
    for($j=1; $j<=$i; $j++){
        echo "* &nbsp;";
    }
    echo "<br>";
}

How to get factorial

<?php 
$fact=1;
$num=5;
for($i=1; $i<=$num; $i++){
    $fact=$fact*$i;
}
echo $fact;
?>

How to check prime

<?php 
$check=0;
$num=10;
for($i=2; $i<=($num/2); $i++){
    if($num%$i==0){
        $check++;
        if($check==1){
            break;
        }
    }
}
if($check==0): "Prime";
?>

How to get Reverse Number Without Predefined Function

<?php

$rev=0;
$num=12;
while($num>1){
    $re=$num%10;
    $rev=(($rev*10)+$re);
    $num=$num/10;
}
echo $rev;
?>

How to Swap Two Number without third variable

<?php 
$a=$a+$b;
$b=$a-$b;
$a=$a-$b;

?>

How to get Fibonacci Series

<?php 
$a=0;
$b=1;
$end=5;
for($i=2;$i<$end; $i++){
    $res=$a+$b;
    $a=$b;
    $b=$res;
}
?>


What is strstr(),stristr()

strstr(): The string function strstr (string all string, string occ ) returns part of all string from the first occurrence of occ to the end of all.

stristr(): This function is case-sensitive, stristr() is identical to strstr() except that it is case insensitive.

 

How to Calculate days between two dates

$dt1=date('Y-m-d');
$dt2=date('Y-m-d');
$days=((strtotime($dt2-$dt1)-strtotime($dt1))/(60*60*24));

Types of the table in Mysql

  • MyISAM
  • HEAP
  • Merge
  • InnoDB
  • ISAM

What is Database maximum length

  • table name: 64 char
  • database name: 64 char
  • column name:64 chars

Redirect https to HTTP

RewriteEngine On
RewriteCond %{HTTPS}% on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Redirect HTTP to https

RewriteEngine On
RewriteCond %{HTTPS}% off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

 

Topics: PHP Interview Questions And Answers

Written by admin

Technical contributor at Easy To Learning. Passionate about software development, clean code, and helping developers learn.

Discussion & Feedback

Ask a Question

Have a coding query or doubt? Ask here and get help from our community.

500 characters remaining
Submitting...
Free Download Projects
Join Telegram Group Join WhatsApp Group
Related Topics:
PHP Interview Questions And Answers

Member Sign In

Forgot?
Signing in...

Don't have an account? Register here

Create Free Account

Register Captcha
Registering...

Already have an account? Sign In

Ask a Question

500 characters remaining
Submitting...

About Easy To Learning

Easy To Learning is a comprehensive programming learning portal offering free, practical, developer-driven tutorials for PHP, Java, Python, Spring, MySQL, CSS, Bootstrap, CakePHP, and more.

Explore community-contributed questions and answers, and download ready-to-run source code projects.

Quick Links

  • Home
  • Questions & Answers
  • Download Projects
  • Blog & Articles
  • Member Login

Community

  • Telegram Group
  • WhatsApp Community
  • Ask a Question
  • Join as Member

Connect With Us

Stay updated with our newest programming tutorials and free open source projects.

© 2026 Easy To Learning. All Rights Reserved.