python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 7, Interview Questions Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
Hypertext Pre-processors

51 Best PHP Interview Questions and Answers - Rasmus Lerdorf

What Is PHP?
PHP stands for “Hypertext Pre-processors”. It is server side scripting language and used for developing web applications and It's allows us to dynamically create generated web pages.

PHP has many frameworks and CMS and used for creating websites.  The PHP is very easy to create sites using its CMS.  
The PHP is an Object Oriented Programming (OOPs) language.

Is multiple Inheritance supported in PHP?
The PHP includes only single inheritance that means a class can be extended only one single class using extended keyword.

What was the old name of PHP?
The OLD name of PHP is - Personal Home Page.

Who Is the father of PHP?
The father of PHP is - Rasmus Lerdorf.
Rasmus Lerdorf created the PHP Scripting Language, authoring the first two versions of the language and participated in the development of later versions led by a group of developers like –
ü  Jim Winstead
ü  Stig Bakken
ü  Shane Caraveo
ü  Andi Gutmans and
ü  Zeev Suraski

What Is the difference between $name and $$name?
The $name is variable whereas $$name is reference variable like $name=Anil and $$name=Singh so $Anil value is Singh.

What is the difference between $var and $$var?
The $var is a variable with a fixed name. $$var is a variable whose name is stored in $var.

What Is the use of "echo" in PHP?
The "echo" used to print a data in the webpage. Its looks like –
  <?php echo 'Demo apps'; ?>

What Is PEAR in PHP?
The PEAR stands for PHP Extension and Application Repository. The PEAR is a framework and repository and used to create the reusable PHP components. It's also provides a command line interface to install "packages" automatically.
The main purpose of PEAR -
ü  A structured library of open-sourced code for PHP users
ü  A system for code distribution and package maintenance
ü  A standard style for writing code in PHP
ü  PHP Foundation Classes (PFC)
ü  PHP Extension Community Library (PECL)

What Is PDO classes in PHP?
The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. It is also data access abstraction layer, so no matter what database we use the function to issue queries and fetch data will be same.

What Is Zend Engine?
The Zend Engine is used internally by PHP as a compiler and runtime engine. The PHP Scripts are loaded into memory and compiled into Zend opcodes and these opcodes are executed and the HTML generated is sent to the client.

What Is the name of scripting engine in PHP?
The scripting engine that powers PHP is called Zend Engine.

What are differences in between PHP4 and PHP5?
The PHP4 doesn't support OOPs concept and it’s using the Zend Engine 1.
The PHP5 supports the OOPs concept and its using the Zend Engine 2.

How do you execute a PHP script from the command line?
The PHP command lines interface (CLI) and specify the file name of the script to be executed as - 
php script.php

How to run the interactive PHP shell from the command line interface?
The PHP CLI program with the option -a as follows -
php -a

How can we display the output directly from the browser?
The tags <?= and ?> is used to display the output directly to the browser.

How To include a file to a PHP page?
The function include () OR require () are using to include a file to a PHP page.

What Are the different type of errors in PHP?
In PHP, contains four types of error -
ü  Parse Error – Commonly caused due to syntax mistakes in codes.
ü  Fatal Error – These are basically run time errors which are caused when you try to access what can’t be done.
ü  Notice Error – These errors occurs when u try to use a variable that hasn’t been declared.
ü  Warning Error – These occurs when u try to include a file that is not present, or delete a file.
What Is the differences between include and require function?
The require () function - The file is required, If file not find - throw Fatal error.
The include () function - If file not find - returns warning not error.

How many data types are there in PHP?
The PHP data types are used to hold different types of data or value and its looks like-
ü  Scalar types
ü  Compound types
ü  Special types

How many Types of Array in PHP?
There are many array functions -
ü  array()
ü  array_change_key_case()
ü  array_chunk()
ü  count()
ü  sort()
ü  array_reverse()
ü  array_search()
ü  array_intersect()

How To declare an Array in PHP?
var $arr = array('Anil', 'Sunil', 'Sushil');

What is the use of "ksort" in PHP?
The “ksort” is used to sort an array by key in reverse order.

What does $GLOBALS means in PHP?
The $GLOBALS is associative array including references to all variables which are currently defined in the global scope of the script.

How do you define a constant?
The constants can be defined using define () directive and its looks like -
define("baseUrl", 'https://code-sample.com');

What Is use of in_array() function in PHP?
The in_array() function is used check the values are exists or not in the existing array collection.

What does $_SERVER means in PHP?
The $_SERVER is an array including information created by the web server such as paths, headers, and script locations.

What does $_FILES means in PHP?
The $_FILES is an associative array composed of items sent to the current script via the HTTP POST method.

How To set cookies in PHP?
To set cookies in PHP is –
Setcookie("demoApp", "web", time()+3600);

How To Retrieve a Cookie Value in PHP?
To Retrieve a Cookie Value is –
echo $_COOKIE["demoApp"];

How can we encrypt password in PHP?
The md5 (), sha1 () and base64_encode () functions are used to encrypt the username and password. We can encrypt the password to a degree with md5 () and the md5 () function would be the best.

Example - As for encryption i would personally use md5 () and a salt.
<?php
  $user = "AnilSingh";
  $pass = "Buy a dring first.";
  $salt = "asdfghjkl!";
  $enc_pass = md5(md5($user . $pass) . $salt);
?>

What Are the differences in explode () and str_split () functions?
The str_split() function splits a string into array by using the regular expression.
The explode() function splits a string into array by using the string.

What's a header () function in PHP?
The header () function is used to sends a raw HTTP header to the client browser.

How to set HTTP header to UTF-8 using?
header(‘Content-Type: text/html; charset=utf-8’);

What Is session in PHP?
The Session is a super global variable that preserve the data across subsequent pages. The Session uniquely defines every user with a session ID and its helps to managing the web apps.
The session_id() returns the session id for the current session.

How can we register the variables into a session?
<?php
  session_register($ur_session_var);
?>

How can we destroy a session in PHP?
<?php
   session_destroy();
?>

What Is cookie in PHP?
The Cookie is a small piece of information that stored in the client browser and also used to identify a user using the information stored in their browsers.

What Are differences in ID and class in CSS?
The ID can be used to identify one element but class can be identifying more than one.
The difference between an ID and Class is that an ID can be used to identify one element, whereas a class can be used to identify more than one.

What Are differences in unset() and unlink() function in PHP?
The unset() function is used to destroy a variable and the unlink() function is used to destroy a file.

What does isset() function?
The isset() function is used to checks, the variable is defined and not null.

How can we submit a form without using submits buttons?
document.getElementById("MyformIds").submit();
document.formname.submit();


What are the methods available in form submitting?
The GET and POST are used to submitting a form.

How can we get the browser properties using PHP?
<?php
  echo $_SERVER[‘HTTP_USER_AGENT’].”\n\n”;
  $browser=get_browser(null,true);
  print_r($browser);
?>

What are predefined classes in PHP?
The predefined classes are -
ü  Directory
ü  stdClass
ü  __PHP_Incomplete_Class
ü  exception
ü  php_user_filter

What are magic methods in PHP?
The Magic methods always start with “__” and Magic methods are member functions that are available to all the instance of class.

The Magic Methods are -
ü  __call()
ü  __toString()
ü  __sleep()
ü  __wakeup()
ü  __isset()
ü  __unset()
ü  __autoload()
ü  __clone()
ü  __construct()
ü  __destruct()
ü  __set()
ü  __get()

What's use of __sleep and __wakeup in PHP?
The __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.

What Are the difference between $message and $$message?
The $message stores variable data and the stored data can be fixed while $$message is used to store variable of variables and the stored data may be changed dynamically.

How can I execute an anonymous function in PHP?
call_user_func(function() { echoanonymous function called.’; });

How To send an email In PHP?
Send an email in PHP using the mail () function and It contain five parameters - $to, $subject, $message and $headers. The $message and $headers are optional parameters.

Example -
<?php
   mail($to,$subject,$message,$headers);
?>

What is the difference between characters \034 and \x34?
The \034 is octal 34 and \x34 is hex 34.

I hope you are enjoying with this post! Please share with you friends!! Thank you!!!
ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions