• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

PHP Interview Questions Answers

Question - 71 : - Can we use include(abc.PHP) two times in a PHP page makeit.PHP”?

Answer - 71 : - Yes we can include that many times we want, but here are some things to make sure of: (including abc.PHP, the file names are case-sensitive) there shouldn't be any duplicate function names, means there should not be functions or classes or variables with the same name in abc.PHP and makeit.php

Question - 72 : - How can we know the count/number of elements of an array?

Answer - 72 : - a) sizeof($array) - This function is an alias of count() b) count($urarray) - This function returns the number of elements in an array. Interestingly if you just pass a simple var instead of an array, count() will return 1.

Question - 73 : - What’s the special meaning of __sleep and __wakeup?

Answer - 73 : - __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.

Question - 74 : - What’s the difference between htmlentities() and htmlspecialchars()?

Answer - 74 : - htmlspecialchars only takes care of <, >, single quote ‘, double quote " and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML.

Question - 75 : - What is meant by MIME?

Answer - 75 : - MIME is Multipurpose Internet Mail Extensions is an Internet standard for the format of e-mail. However browsers also uses MIME standard to transmit files. MIME has a header which is added to a beginning of the data. When browser sees such header it shows the data as it would be a file (for example image) Some examples of MIME types: audio/x-ms-wmp image/png application/x-shockwave-flash Multipurpose Internet Mail Extensions. WWW's ability to recognize and handle files of different types is largely dependent on the use of the MIME (Multipurpose Internet Mail Extensions) standard. The standard provides for a system of registration of file types with information about the applications needed to process them. This information is incorporated into Web server and browser software, and enables the automatic recognition and display of registered file types.

Question - 76 : - How can we extract string 'abc.com ' from a string http://info@abc.com using regular expression of php?

Answer - 76 : -  We can use the preg_match() function with "/.*@(.*)$/" as the regular expression pattern. For example: preg_match("/.*@(.*)$/","http://info@abc.com",$data); echo $data[1];

Question - 77 : - How can we extract string "abc.com" from a string "mailto:info@abc.com?subject=Feedback" using regular expression of PHP?

Answer - 77 : - $text = "mailto:info@abc.com?subject=Feedback"; preg_match('|.*@([^?]*)|', $text, $output); echo $output[1]; Note that the second index of $output, $output[1], gives the match, not the first one, $output[0].

Question - 78 : - How many ways can we get the value of current session id?

Answer - 78 : - session_id() returns the session id for the current session.

Question - 79 : - What is meant by urlencode and urldecode?

Answer - 79 : - 1) -urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode("10.00%") will return "10%2E00%25". URL encoded strings are safe to be used as part of URLs. urldecode() returns the URL decoded version of the given string. 2) - string urlencode(str) - Returns the URL encoded version of the input string. String values to be used in URL query string need to be URL encoded. In the URL encoded version: Alphanumeric characters are maintained as is. Space characters are converted to "+" characters. Other non-alphanumeric characters are converted "%" followed by two hex digits representing the converted character. string urldecode(str) - Returns the original string of the input URL encoded string. For example: $discount ="10.00%"; $url = "http://exammaterial.com/submit.php?disc=".urlencode($discount); echo $url; You will get "http://exammaterial.com/submit.php?disc=10%2E00%25".

Question - 80 : - What is the difference between CHAR and VARCHAR data types?

Answer - 80 : - CHAR is a fixed length data type. CHAR(n) will take n characters of storage even if you enter less than n characters to that column. For example, "Hello!" will be stored as "Hello! " in CHAR(10) column. VARCHAR is a variable length data type. VARCHAR(n) will take only the required storage for the actual number of characters entered to that column. For example, "Hello!" will be stored as "Hello!" in VARCHAR(10) column.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners