PHP Interview Questions
PHP Interview Questions
PHP Interview Question for Freshers
What is PHP ?
PHP stands for Hypertext Preprocessor It is open source server side scripting language. It support many database for example: MySQL, Oracle, Sybase, Solid, PostgreSQL, generic ODBC etc.
Why use PHP ?
It is used for design server side code.
What is PEAR in PHP ?
PEAR stands for PHP Extension and Application Repository. It contains all types of PHP code snippets and libraries.
Who is father of PHP ?
Father of php is; Rasmus Lerdorf
What was the old name of PHP ?
Personal Home Page.
Difference b/w static and dynamic websites ?
Static websites, content can't be changed after running the script.Dynamic websites, content of script can be changed at the run time. Example of dynamic website are; Google, Yahoo, Facebook etc.
Name of scripting engine in PHP ?
The scripting engine that powers PHP is called Zend Engine 2.
Difference between PHP4 and PHP5. ?
PHP4 doesn't support oops concept and uses Zend Engine 1. PHP5 supports oops concept and uses Zend Engine 2.
Difference between "echo" and "print" in PHP ?
Print return value but echo not return any value .Echo is faster than print because it does not return any value.
Differentiate between require and include? ?
Require and include both are used to include a file, but if file is not found include sends warning whereas require sends Fatal error.
popular Content Management Systems (CMS) in PHP ?
Some popular CMS in php are given below;
- WordPress
- Drupal
- Joomla
- Magento
Use of count() function in PHP ?
Count() function is used to count total elements in the array, or something an object.
Difference between session and cookie ?
The main difference between session and cookies is that cookies are stored on the user's computer in the text file format while sessions are stored on the server side.You can manually set an expiry for a cookie, while session only remains active as long as browser is open.
How can you retrieve a cookie value ?
Syntax
echo $_COOKIE ["user"];
How to download file in PHP ?
Using readfile() function you can download file in PHP.
Syntax
int readfile ( string $filename )
How to delete file in PHP ?
Using unlink() function you can delete file in PHP.
Syntax
bool unlink (string $filename)
How can you send email in PHP ?
Using mail() function you can send email in PHP.
Syntax
bool mail($to,$subject,$message,$header);
Different loops in PHP ?
Loops supported by PHP are; for, while, do..while, for each.
How can you submit a form without a submit button ?
Using JavaScript submit() function you can submit the form without explicitly clicking any submit button.
Why use strlen() function in php ?
In php strlen() function is used to get the length of string.
Explain "GET" and "POST" methods.
Both the methods are used to send data to the server. GET method - the browser appends the data onto the URL and it is visible in URL.Post method - the data is sent as standard input and data not visible in URL.
What is the array in PHP ?
In PHP array are used to store multiple value in single variable
How to create connection in PHP ?
Using mysqli_connect() function you can create connection in PHP.
Syntax
resource mysqli_connect (server, username, password)
What is $text vs. $$text in PHP ?
$text is a variable with a fixed name. $$text is a variable whose name is stored in $text .If $text contains "var", $$text is the same as $var.
How to stop the execution of PHP script ?
Using exit() function you can stop the execution of PHP script.
How will you find out the value of current session id ?
Using session_id() find out the value of current session id.
What are the popular frameworks in PHP ?
Some popular frameworks in php are given below;
- Symfony
- CodeIgniter
- Yii 2
- Symfony
- Zend Framework
How will you create a database using PHP and MySQL ?
Using mysql_create_db("Database Name") you can create a database using PHP and MySQL.
Which programming language does PHP resemble to ?
PHP has borrowed its syntax from Perl and C.
How to connect MySQL database with PHP ?
There are two methods to connect MySQL database with PHP.
- Procedural
- object oriented style.
types of errors in PHP ?
There are 3 types of error in php which are geven below;
- Notices: These types of error are the non-critical errors. These errors are not displayed to the users.
- Warnings: These types of error are more serious errors but they do not result in script termination. By default, these errors are displayed to the user.
- Fatal Errors: These types of error are the most critical errors. These errors may be a cause of immediate termination of script.
Encryption functions in PHP ?
Encryption functions in php are; CRYPT() and MD5()
Give method to register a variable into a session ?
Syntax
<?php Session_register($ur_session_var); ?>
What is a session ?
PHP Engine creates a logical object to preserve data across subsequent HTTP requests, which is known as session. Sessions generally store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same user.
What are the methods of form submitting in PHP ?
There are two methods GET and POST.