Imp Interview Questions

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Imp Interview Questions as PDF for free.

More details

  • Words: 4,155
  • Pages: 23
(1) What is PHP? Ans.PHP is a server-side scripting language and it stands for "PHP Hypertext Preprocessor" which is use for web developement or making web applications. (2)Why use PHP? Ans:(i)The main reason behind this is that it is free of cost (ii) and easy to learn (iii) it is directly embedded in html (iv) It is runs on different plateform like:-(windows,Linux,Unix etc.) (v) PHP is compatible with all servers used today (Apache, IIS etc.). (3) Why you can't see php source code by selecting "ViewSource"? Ans: Because, php script are executed on server. (4)What is the difference between echo() and Print().? Ans:(i) echo() is more faster than print() (ii) print() returns whereas echo() doesn't return (iii) echo() prints multiple value without a blank space when seprated by the commas whereas print() inserts a single blank space with each commas. (5)Why we use (.) operator in PHP? Ans:It is used to concatinate the two or more variables. (6) What is an Array? Ans:An array is a collection of similar datatype or it is data structure that can store one or more value in a single value.In PHP arrays are actually maps(each key is maped to a value). (7) what is associative arrays? Ans:In an associative array a

key is associated with a value. If you wanted to store the salaries of your employees in an array, a numerically indexed array would not be the best choice. Instead, we could use the employees names as the keys in our associative array, and the value would be their respective salary (8) what is the difference between for and foreach loop? Ans:In php, a for loop is used when we knows that how many times we have to execute a block of code or a statement whereas foreach statement is used to loop through array . (9) what is the output of it Ans: it will print echo. (10) Who is the father of PHP? Ans: Rasmus Lerdorf (11) what is function? Ans:A function is a block of code that can be executed whenever we need it. (12) what is the difference between $_GET and $_POST? Ans:(i)Both are used to retrieve the information from a form,like user input(ii)in $_GET , input values are visible in the browser's address bar but in case of $_POST it doesn't(iii) in $_GET variable has character length (Max. 100 character) (iv) we use $_GET when form method="GET" and we use $_POST when method="POST". (v) $_GET variable should not be used hen sending password or some sensitive information.(vi)$_POST variable have no length limit and input data are invisible in this case. (13) what is the default method of form? Ans: GET

(14) Suppose we have a variable $x= 10 then what will be the output when we print $$x? Ans: nothing (15) what does this function strstr()? Ans: It removes the part(needle) before the heystack.if needle is not a string then it converts in to an integer anf if needle is not found then it returns false.for e.g:-
$email = '[email protected]'; $domain = strstr($email, '@'); echo $domain; // prints @example.com ?> (16) what is use of $_REQUEST variable? Ans:It contains the content of both $_GET ,$_POST and $_COOKIE. and it can be used to get the result from form data sent with both GET and POST method. (17) What is a timestamp in date? Ans A timestamp is the number of

seconds since January 1, 1970 at 00:00:00 GMT. This is also known as the Unix Timestamp. (18) what is script-language? Ans:A programming language that uses commands in the form of Englishstatements.Early script languages were often called batch languages or job control languages (19) what is web-applications? Ans: A web application is an application delivered to users from a web server over a network such as the World Wide Web or an intranet. Web applications are popular due to the ubiquity of the web browser as a client, sometimes called a thin client. The ability to update and maintain web applications without distributing and installing software on potentially thousands of client computers is a key reason for their popularity (20) What is web development? Ans: Web development incorporates all areas of creating a Web site for the World Wide Web. This includes Web design (graphic design, XHTML, CSS, usability and semantics), programming, server administration, content management, marketing, testing and deployment. The term can also specifially be used to refer to the "back end", that is, programming and server administration. There are usually more than one member that works on a given Web Development team, each specialising in his or her own field. (21)Why we use addslashes()? Ans:Addslashes() function return a string with backslash before the predefined character.This function can be used to prepare a string for storage in a database and database query. (22) What are predefined character? Ans:Predefined characters are:•

single quote (')



double quote (")



backslash (\)



NULL

(23) what are HTML-Entities? Ans:Convert all applicable characters to HTML Entities.Some times we have value in a database like:-its"mine'<> and when we fetch this value from a database it doesn't come exact as we entered .At that time we use html-entities for fetching the exact value. for e.g bold";

echo htmlentities($str, ENT_QUOTES); // Outputs: A 'quote' is <b>bold</b> ?> (24) What is nl2br()? Ans:Insert html line breaks before all newline in a string. Some times when user enters comment in a textarea field and then when we fetch that value we didn't see like that or as user has entered.in that case we use this function.For e.g :
(25)why we use WordWrap() function? Ans This function raps a string in to new lines when it reaches a specific length .

An example on a long word is: Supercalifragulistic (26)Why we use explode()? Ans:The explode() function breaks a string into an array. Output:-Array (

[0] [1] [2] [3] [4] [5] )

=> => => => => =>

Hello world. It's a beautiful day.

(27)what is the MD5()? Ans:This function is use for security pupose.The md5() function calculates the MD5 hash of a string. For e.g:
$str = "Hello"; echo md5($str); ?> output:8b1a9953c4611296a827abf8c47804d7

(28)How we can find the length of an array? Ans:There are two ways one is Count() and another is Sizeof(). (29)How we can send mail through php? Ans:-We can send the mail by a function i.e.mail()

Like:-mail(to,subject,message,headers,parameters)

(30)How we can combine two arrays? Ans:We can combine the two arrays with array_merge() function or array_combine() function. For e.g:"Horse","b"=>"Dog"); $a2=array("c"=>"Cow","b"=>"Cat"); print_r(array_merge($a1,$a2)); ?> Output:Array ( [a] => Horse [b] => Cat [c] => Cow )

(31) If we have to check a function is exists ot not. then what we have to do? Ans we can do with "function_exists(function name)"function . (32) Why we use Urlencode()? Ans:Returns a string in which

all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs.Thi function is convienient when we use a encodig string in the query part of a url to pass variables to next page.

(33)what is urldecode? Ans:Decodes any %## encoding in the given string. The decoded string is returned. (34)why we use var_dump()? Ans:This function displays structured information about one or more expressions that includes its type and value. Arrays and objects are explored recursively with values indented to show structure.For e.g: Output:(array(3) { [0]=> int(1) [1]=> int(2) [2]=> array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" } }

(35)why we use isset()? Ans:We use it for checking a variable is set or not. (36)How we can find out the length of a string in php? And we can dor it with strlen() function.For e.g: (37) What is the diffrenece between unset() and unlink()? Ans:We use unset() to destroy any variable or an array element whereas unlink() is use for deleting a file. (38)Why we use array_push()? Ans:Array_push() push the passed variable on to the end of the array. for e.g:-

Output:Array ( [0] => orange [1] => banana [2] => apple [3] => raspberry ) ?> (39)Why we use array_sum()? Ans:array_sum() returns the sum of values in an array as an integer or float. Output:sum(a)=20

(40)Why we use floor()? Ans:Returns the next lowest integer value by rounding down value if necessary. The return value of floor() is still of type float because the value range of float is usually bigger than that of integer. For e.g: ouput:- 4 (41)which three different tags are there for using PHP? Ans:(i) (ii) (iii) <script language="php">-- (42)How we can know that our web host is supporting php or not? Ans:For this we can run any php file on to the host if this file offers for download means your host is not supporting php. (43)What is mysql? Ans:MySQL is a database. A database

is a data storage area.

(44)What is a query? Ans:A query is a question or a request.With MySQL, we can query a database for a

specific part and have a result-set returned. (45)How we can connect to a mysql database using php? Ans:We can connect to a mysql database using php with a function i.e mysql_connect(host,username,password). It takes three parameter which are optional.Degault value for host is"localhost:3306" and username is owner of the server and password is "". (46)What is the difference between varchar and char datatype? Ans:(i) Both are used for storing alphabets, numeric value and alphanumeric value. (ii) The main diff. is "covered bytes".suppose we have 10 bytes of space for a datatype and we have to store a name "pawan". In char case it will take 10 bytes but in varchar it will take 5 bytes only and remaining 5 bytes will be free. (47)What is a primary key? Ans: It is used for uniqueness.Each table should have an unique identifier field. (48)Why we use array_pop()? Ans:Deletes the last element of an array.For e.g:

Output:-

Array ( [0] => Dog [1] => Cat )

(49)What are the predefined variables in php? Ans:$GLOBALS,$_REQUEST,$_POST,$_GET,$_COOKIE,$_SESSION,$_FILES,$_E NV are predefined variables. (50)Why we use is_numeric() in php? Ans:Finds whether the given variable is numeric. (51)What is the diffrenece between split() and explode()? Ans:(i)Split() function split a string in to array by regular expression whereas explode() does the same but it doesn't require regular expression.(ii)Both return false if seprator or regular expression is empty See below an e.g of split():\n"; ?> Output:-Month:

04; Day: 30; Year: 1973

E.g of explode():-


?> (52) Why we use list()? Ans: This is used to assign a list of variable in one operation.list() only works on numerical arrays and assumes the numerical indices start at 0. for e.g: (53)what is the diffrence between explode() and imlode()? Ans:Explode function split a string in to an array where as implode combine the arrray elements in to a string. an e.g of implode is: E.g of explode():
?> (54)What is difference between Session and Cookie? Ans:A cookie is store small bit of information on user's computer like(username,password etc.). It stores information for long time and automatic deletes after some time and stores in a commonly named folder anyone with access someone else computer and can open the file and delete the information.So it is not ideal.A session does the same thing but it cannot store information more than the length of the time.when a user close the browser an information will be lost

(55)What is the difference between mysql_connect and mysql_pconnect? Ans:Evertime when when we run php file a conection is open and automatically close in the end of the scripts in case of mysql_connect but in case of mysql_pconnect it uses persistent connection it doesn't close connection and connection is open till we restart the computer.when we connect through mysql_pconnect php checks if any already persistent connection(link) is exists or not it exists with same host,username and password then it uses that connection instead of open a new connection.

(56)What is the difference between GroupBy and OrderBy? Ans:GroupBy:-When using the GROUP BY clause in your SQL statement, you will only select the distinct values of that query.This function is often used with the aggregate functions.For e.g:[Users]

[SQL Statement]

[result]

Name

Points

SELECT SUM(Points), Name FROM Users GROUP BY Name

Name

Points

Jon

1

Jon

6

Jessie

13

Jessie

13

Wendy

3

Wendy

3

Jon

5

OrderBy:-We used this function for sorting records by specifying field.You can also use with DESC or ASC for 'descending' or 'asending' order.For e.g:Name Address

[SQL Statement]

[result ] Name Address

SELECT * FROM Users Jessie 5116 Gopher CaddyShack Dr ORDER BY Name DESC Abe

1342 haha lane

Abe

1342 haha lane

Jessie 5116 Gopher CaddyShack Dr

Wend 2922 Samurai Jackville y

Jondy 1911 North Pole Blvd

Jondy 1911 North Pole Blvd

Wend 2922 Samurai Jackville y

(57)How we can fetch "abc.com" from a string "HTTP:\\[email protected]" using regular expression in php? Ans: echo substr("http:\\[email protected]",11,19); (58)How we can get the first n rows from a table? Ans:We can do like this: for e.g:-$result = mysql_query("SELECT id FROM table LIMIT 10"); if we have to fetch only first ten records. (59) which are the aggregate funtions? Ans: there are some aggregate functions like:-SUM(),MAX(),MIN(),AVG() etc. (60)How can we register the variables into a session? Ans:session_register($ur_session_var); (61)How can i execute a php script using command line? Ans:As of version 4.3.0, PHP supports a new SAPI type

(Server Application Programming Interface) named CLI which means Command Line Interface. (62)What are the current versions of apache, PHP, and mysql? Ans:The Current version are 2.2.3 , 5.1.0 , 5.0. (63)Why we use Inner-Join? Ans:-when we have to fetch one or more rows from two or more related tables.For e.g:-

[Users] UserID

GroupID

Name

1

1

Mason

2

1

Beric

3

2

Slavic

4

5

Tammy

5

3

Dave

[SQL Statement] SELECT Users.UserID, Users.Name, Groups.GroupName FROM Users INNER JOIN Groups ON Users.GroupID = Groups.GroupID

[Groups]

GroupID

GroupName

1

Cool Guys

2

Banned Members

3

Sleepy Peppers

[result] UserID

Name

GroupName

1

Mason

Cool Guys

2

Beric

Cool Guys

3

Slavic

Banned Members

5

Dave

Sleepy Peppers

(64)Why we use Left-Join? Ans:-Left Join selects all the data in the first table, and if there were related matches in the second table that data will be displayed as well. If there is any data in the second table that does not directly relate to the first table, that data will not be returned.For e.g:[Users] UserID

GroupID

Name

1

1

Mason

2

1

Beric

3

2

Slavic

4

5

Tammy

5

3

Dave

[SQL Statement] SELECT * FROM Users LEFT JOIN Groups ON Users.GroupID = Groups.GroupID

[Groups] GroupID

GroupName

1

Cool Guys

2

Banned Members

3

Sleepy Peppers

[result] UserID

Name

GroupName

1

Mason

Cool Guys

2

Beric

Cool Guys

3

Slavic

Banned Members

4

Tammy

5

Dave

Sleepy Peppers

(65)Why we use right-join? Ans:-Right Join selects all the data in the second table, and if there were related matches in the first table that data will be displayed as well. If there is any data in the first table that does not directly relate to the second table, that data will not be returned.For e.g:[Users] UserID

GroupID

Name

1

1

Mason

2

1

Beric

3

2

Slavic

4

5

Tammy

5

3

Dave

[SQL Statement] SELECT * FROM Users RIGHT JOIN Groups ON Users.GroupID = Groups.GroupID

[Groups] GroupID

GroupName

1

Cool Guys

2

Banned Members

3

Sleepy Peppers

4

Doom Bringers

[result] UserID

Name

GroupName

1

Mason

Cool Guys

2

Beric

Cool Guys

3

Slavic

Banned Members

5

Dave

Sleepy Peppers

(66)what is Join? Ans:-This is a useful command when you want to select data from two related tables with one query. (67)Why we use BETWEEN? Ans:-The BETWEEN ... AND operator selects a range of data between two values. These values can be numbers, text, or dates. This command reacts differently on different servers.For e.g:[Names]

[SQL Statement]

[result]

LastName

FirstName

SELECT * FROM Users WHERE LastName BETWEEN 'Tilson' AND 'Sniper'

LastName

FirstName

Amtode

Mason

Tilson

Beric

Tilson

Beric

RoseBlotch

Slavic

RoseBlotch

Slavic

Fay

Tammy

Fay

Tammy

Sniper

Dave

(67)Why we use IN? Ans:-IN can be used if you know one of the values that you would like to return.For e.g:[Users]

[SQL Statement]

LastName

FirstName

Amtode

SELECT * FROM tableName WHERE firstName IN ('Mason', 'Tammy')

[result]

LastName

FirstName

Mason

Amtode

Mason

Tilson

Beric

Fay

Tammy

RoseBlotch

Slavic

Fay

Tammy

Sniper

Dave

(68)What are the different types of errors in PHP? Ans:- There are three types of errors in PHP i.e Fatal error , Parser error , Startup error. (69)What is the difference between ereg_replace() and eregi_replace()? Ans:-eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters. (70)45. How many ways we can pass the variable through the navigation between the pages? Ans:-GET or QueryString and POST (71)What is the difference between mysql_fetch_object and mysql_fetch_array? Ans:-Both does the same work but the diffrence is an object is returned in mysql_fetch_object while an array is returned in mysql_fetch_array. OR mysql_fetch_object is like fetching value from a recordset and mysql_fetch_array is gettin array’s value (72)Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”? Ans: yes (73)What is the difference between ereg_replace() and eregi_replace()? Ans:-eregi_replace() is identical to ereg_replace() but it ignores the case distinction when

matching alphabetic characters. (74)How can we register the variables into a session? Ans:- $_SESSION['name of field'] = field value (75)How can I know that a variable is a number or not using a JavaScript? Ans:is_numeric ( mixed var) .Returns TRUE if var is a number or a numeric string, FALSE otherwise. (76)LIST OUT THE TOOLS USED FOR DRAWING ER DIAGRAMS. Ans;-Case Studio Smart Draw (77)16. HOW CAN WE ENCRYPT AND DECRYPT A DATA PRESENT IN A MYSQL TABLE USING MYSQL? Ans:-AES_ENCRYPT(str,key_str) , AES_DECRYPT(crypt_str,key_str) (78)How we can encrycpt data using PHP? Ans:Using Crypt(), MD5() etc. (79) What are the different tables present in mysql,which type of table is generated when we are creating a table in the following syntax: create table employee(eno int(2),ename varchar(10)) ? Ans :Total 5 types of tables we can create 1. MyISAM 2. Heap 3. Merge 4. INNO DB 5. ISAM MyISAM is the default storage engine as of MySQL 3.23. (80)How can we create a database using PHP and mysql? Ans : mysql_create_db(”Database_Name”); (81)Why we use Alias? Ans:It is a way to give different name to columns in the result.

Users]

[SQL Statement]

[result]

Name

SELECT Name AS UserName FROM Users

UserName

Nogame

Nogame

Z3ro c00l

Z3ro c00l

Nappy Wap

Nappy Wap

(82)How can we get the properties (size, type, width, height) of an image using PHP

image functions? Ans: getimagesize — Get the size of an image image_type_to_extension — Get file extension for image type imagesx — Get image width imagesy — Get image height (83)How do I get the visitors browser information? Ans:You have more than one option when you want to get the information, they depends on how much information you want to get bout the browser. We will mention two ways here. The first way to do it is simply by using the variable $HTTP_USER_AGENT, which holds information about browser version, name etc. The second one is to use php's get_browser function, though it has it drawbacks, because you need a browsercap.ini which has to be present at your isp, it gives much more information than other ways. (84)How do I find out how a user came to my page? Ans:You have the variable $HTTP_REFERER which holds the page that refered to you page, if there are any referer, ie if the user enters your url directly the referer variable will be empty. (85)How do I insert javascript in php code? Ans:You just echo / print the javascript like you would do with html, like:
echo "<script language=\"JavaScript\">\n"; echo "alert("javascript from php");\n"; echo ""; ?>

(86)How do I check whether a string contains HTML? Ans:There are two ways you can do it, one is using a regular expression the other is comparing strings. First the regular expression approach: if (preg_match("/([\<])([^\>]{1,})*([\>])/i", $string)) { echo "string contains html"; } And here is the other approach: if(strlen($string) != strlen(strip_tags($string)){ echo "string contains HTML"; }

(87)How we can clean the session?

Ans: session_unset(); (88)How we can get the a random row in through mysql? Ans:Some time we need a random row from database for this mysql has a function named RAND().For e.g:Select Id from table order by RAND(). (89)How we can find the position of char in php? Ans:If you want to find the first occurrence of a char in a string you can do: $string = "Hello World"; $first_position = strpos($string, "l"); print $first_position; Output:-2 To find the last last occurrence of a char in a string you can do the following: $string = "Hello World"; $last_position = strrpos($string, "l"); print $last_position ; Output:-9 (90)How we can get the number of char from a string? Ans:-To

get a number of chars from a string you for example use substr(). To get char 3

to 5 do: $string = "This is a test string"; $new_string = substr($string, 3, 2); print $new_string;

Output:- s This tells substr to start cutting at char 3 and stop 2 chars later at char 5. (91)How do you refresh a PHP page into itself? Ans:Add a line like this in the section of your page: <META HTTP-EQUIV=Refresh CONTENT="X; URL="> Where X is number of seconds before the page refreshes.

(92)How do we move the user on to a page? Ans:-You can redirect a user to a new script with the header ( )function.You must include a location header. Header(“Location:membersmenu.php?â€SID); (93)Why we use of mysql_num_fields()?

Ans: We use this function to find out how many numbers of fields are there. For e.g Ouput:- 5 (94)Why we use of Mysql_fileds_type()? Ans:-We use this function to find which type of fields it have. For e.g Output:- String (95)Why we use mysql_list_dbs()? Ans:-This function shows list of availaable database in mysql.It has one parameter i.e Connection. For e.g. Database . "
"; } mysql_close($con); ?>

The output of the code above could be: mysql test test_db

(96)Why we use mysql_info()? Ans: This function give the information about last query.For e.g: Output:-String format: Records: 15 Duplicates: 0 Warnings: 0

(97)How do I call two functions from the body tags onLoad event handler? Ans:As with other JavaScript statements separate them with a semi-colon: Like this:- (98)How do I detect the version of JavaScript the users browser supports? Ans:-We can do like this:-

<script language="JavaScript"> <script language="JavaScript1.1"> <script language="JavaScript1.2"> <script language="JavaScript"> (99)How to convert decimal values to characters? Ans:Based on some friendly advice will here my revised verion if $decimal is a variable with your decimal value in it. echo chr($decimal); will print out the character (100)What does HTTP stand for? Ans:-HTTP stands for hypertext transfer protocol.

Related Documents

Imp Interview Questions
October 2019 17
Imp Questions
June 2020 34
Interview Questions
May 2020 25
Interview Questions
October 2019 24
Interview Questions
November 2019 24
Interview Questions
November 2019 20