php_interview_question



1.What is PHP?
Ans. PHP stands for hyper text preprocessor language and this is used for only web based application  means online for web development and PHP is a server-side scripting language but also used as a general-purpose programming language.

2.What is “echo” in php?
Ans.  “echo” is used for print the data of the website,
 Example of “echo” keyword is
<?php
Echo “this is realphplearnwebsite”;
?>
o/p :- this is realphpwebsite.
Echo is work like printf in C language.
3.How many loops and what types of loops exist in php?
 Ans.  Four  loop are present in php language and

They are
            for
           while
         do while
         foreach


 4. what is oops Methodology .
  Ans. Oops is a software or Web  methodology that is based on the modeling a real world system.An object is the core concept involved in the object orientation. An object is the copy of the real world entity

5.Different errors in PHP?
Ans.three types of error are present in php programming.
(a)Warnings:
These are important errors. Example: When we try to include () file which is not available. These errors are showed to the user by default but they will not result in ending the script.
(b)Notices:
These errors are non-critical  that come across while executing the script in PHP. 
(c)Fatal errors:
These are critical errors. Example: instantiating an object of a class which does not exist or a non-existent function is called.

6.How do you connet mysql database with PHP ?
Ans. We can connect Mysql Database with PHP using both Procedural  style.

$conn = mysqli_connect("localhost", "username", "password", );
here $conn is a variable  and  localhost , username, password is the parameter.

7.What is the difference b/w include() and required() function.
Ans.they are used for include a file  but when included file not found
Include send Warning where as Require send Fatal Error.
8. Maximum length of a table name, database name, and
field name in MySQL?
Ans.
Identifier       Maximum Length
(bytes)
Database               64
Table         64
Column         64
Index         64
Alias         255
8.What is the difference b/w static and dynamic website.
Ans. Static website is one that is develop in HTML only .every page have different document and page. in which no database is used. it is easily edit in HTML.
and a dynamic website that is develop in any strong language like php, asp.net etc.and dynamic website  have database and they retrieve data from database.

9.What Is a Session in PHP?
Ans.It can be used to store information on the server for future use.

10.Is variable name case sensitive in php?
Ans. Yes variable name case sensitive and we can not start a variable with number like $6name as a valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
Q11. What is PEAR in PHP?
Ans .PEAR stands for PHP Extension and Application Repository. PEAR is provide command-line interface that is  used for  automatically install "packages".  It is a framework and for reusable PHP components. PEAR is a code repository containing all kinds of PHP code snippets and libraries.


Q12.What is MIME in PHP?
Ans.MIME stands for Multi-purpose Internet Mail Extensions.It represents a standard way of classifying file types over Internet.A MIME type has two parts:
_A type
_A subtype
They are separated by a slash (/). Web servers and browsers have a list of MIME types, which facilitates files transfer of the same type in the same way, irrespective of operating system they are working in.

Q13.What is the Fatal errors in PHP?
Ans.Fatal errors are critical errors i.e. calling a non-existent function or class. These errors cause the immediate termination of the script.

Q14.How do you define a constant?
Ans.Using define() directive, like define ("MYCONSTANT",150)

Qsn.15How send email using php?
Ans.To send email using PHP, you use the mail() function.This mail() function accepts 5 parameters as follows (the last 2 are optional). You need webserver, you can't send email from localhost. eg : mail($to,$subject,$message,$headers);

Qsn.16.How to find current date and time?
Ans.The date() function provides you with a means of retrieving the current date and time, applying the format integer parameters indicated in your script to the timestamp provided or the current local time if no timestamp is given. In simplified terms, passing a time parameter is optional - if you don't, the current timestamp will be used.

Qsn..17Difference between mysql_connect and mysql_pconnect?
Ans.There is a good page in the php manual on the subject, in short mysql_pconnect() makes a persistent connection to the database which means a SQL link that do not close when the execution of your script ends. mysql_connect()provides only for the databasenewconnection while using mysql_pconnect , the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection... the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use.

Qsn.18.What is the use of "ksort" in php?
Ans.It is used for sort an array by key in reverse order.
what is the use of rand() in php language?
rand() function in used to generate random numbers in php.Ii give a result of random no b/w given value. for e.g. If we want to random number between 0 and 10 than we use rand function.It ismostly use for make a capture in signup.

Qsn. 19What is the use of isset() in php?
Ans.  This function is used to determine if a variable is set and is not NULL.

Qsn. 20 What is mean by an associative array?
Ans.  Associative arrays are arrays that use string keys is called associative arrays.

Qsn.21What is the importance of "method" attribute in a html form?
Ans.  "method" attribute determines how to send the form-data into the server.We use to type of method in php or any webdevelopment language for design a web form. they are GET and POST method.if we dont declare any type of method than it is GET by defult.

Qsn.22 Define Object-Oriented Methodology
Ans. Object orientation is a software/Web development methodology that is based on the modeling a real world system.An object is the core concept involved in the object orientation. An object is the copy of the real world enity.An object oriented model is a collection of objects and its inter-relationships

Qsn23. How to set cookies in PHP?
Ans.  Setcookie("sample", "ram", time()+3600);
in php we can use 5 parameters in setcookie and but in above e.g we used jsut 3 parameters.

Qsn24. How to retrive cookies in PHP?
Ans. Echo $_COOKIE[user]";

Qsn25. how to create a session in php?
Ans. the create syntax  session in php is :- SESSION_start();
and set a session value  in php :  $_session["user_id"];
Qsn26. use of explode() function in php ?
Ans. Syntax of explode is :  array explode(string $delimiter , string $string[, int$limit]);
this is use for break a string into array.

Qsn27. use of trim function in php?
Ans. use for remove white space and predefined character.

Qsn28. how to redicect a page in php?
Ans.  Header("location:index.php"); this code is use for redirect any page;




No comments: