PHP Interview Question & Answer

PHP Interview Question and Answer


31. How to set a page as a home page in a php based site?

index.php is the default name of the home page in php based sites

32. How to find the length of a string?

strlen() function used to find the length of a string

33. what is the use of rand() in php?

It is used to generate random numbers.If called without the arguments it returns a pseudo-random integer between 0 and getrandmax(). If you want a random number between 6 and 12 (inclusive), for example, use rand(6, 12).This function does not generate cryptographically safe values, and should not be used for cryptographic uses. If you want a cryptographically secure value, consider using openssl_random_pseudo_bytes() instead.

34. what is the use of isset() in php?

This function is used to determine if a variable is set and is not NULL

35. What is the difference between mysql_fetch_array() and mysql_fetch_assoc()?

mysql_fetch_assoc function Fetch a result row as an associative array, Whilemysql_fetch_array() fetches an associative array, a numeric array, or both

36. What is mean by an associative array?

Associative arrays are arrays that use string keys is called associative arrays.

37. What is the importance of "method" attribute in a html form?

"method" attribute determines how to send the form-data into the server.There are two methods, get and post. The default method is get.This sends the form in formation by appending it on the URL.Information sent from a form with thePOST method is invisible to others and has no limits on the amount of information to send.

38. What is the importance of "action" attribute in a html form?

The action attribute determines where to send the form-data in the form submission.

39. What is the use of "enctype" attribute in a html form?

The enctype attribute determines how the form-data should be encoded when submitting it to the server. We need to set enctype as "multipart/form-data"when we are using a form for uploading files

40. How to create an array of a group of items inside an HTML form ?

We can create input fields with same name for "name" attribute with squire bracket at the end of the name of the name attribute, It passes data as an array to PHP.
For instance :



1 2 3 4 5 6