Interview Questions For PHP Programmers

October 19, 2008 – 10:46 pm


Here are few interesting interview questions which may ask to you in  php interviews.  So lets checkout and solve it all. You can share you answers here and ask for your doubts too. Have a happy learning.

Please post your answers with respective question #.

1. What are the differences between Get and post methods in form submitting, give the case where we can use get and we can use post methods?

2. Who is the father of php and explain the changes in php versions?

3. How can we submit from without a submit button?

4. How many ways we can retrieve the date in result set of mysql using php?

5. What is the difference between mysql_fetch_object and mysql_fetch_array?

6. What is the difference between $message and $$message?

7. How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’ using regular expression of php?

8. How can we create a database using php and mysql?

9. What are the differences between require and include, include_once?

10. Can we use include (”abc.php”) two times in a php page “makeit.php”?

11. 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)) ?

12. Functions in IMAP, POP3 AND LDAP?

13. How can I execute a php script using command line?

14. Suppose your Zend engine supports the mode <? ?> Then how can u configure your php Zend engine to support <?php ?> mode ?

15. Shopping cart online validation i.e. how can we configure the paypals?

16. What is meant by nl2br()?

17. Draw the architecture of Zend engine?

18. What are the current versions of apache, php, and mysql?

19. What are the reasons for selecting lamp (linux, apache, mysql, php) instead of combination of other software programmes, servers and operating systems?

20. How can we encrypt and decrypt a data present in a mysql table using mysql?

21. How can we encrypt the username and password using php?

22. What are the features and advantages of OBJECT ORIENTED PROGRAMMING?

23. What are the differences between PROCEDURE ORIENTED LANGUAGES AND OBJECT ORIENTED LANGUAGES?

24. What is the use of friend function?

25. What are the differences between public, private, protected, static, transient, final and volatile?

26. What are the different types of errors in php?

27. What is the functionality of the function strstr and stristr?

28. What are the differences between PHP 3 and PHP 4 and PHP 5?

29. How can we convert asp pages to php pages?

30. What is the functionality of the function htmlentities?

31. How can we get second of the current time using date function?

32. How can we convert the time zones using php?

33. What is meant by urlencode and urldocode?

34. What is the difference between the functions unlink and unset?

35. How can we register the variables into a session?

36. How can we get the properties (size, type, width, height) of an image using php image functions?

37. How can we get the browser properties using php?

38. What is the maximum size of a file that can be uploaded using php and how can we change this?

39. How can we increase the execution time of a php script?

40. How can we take a backup of a mysql table and how can we restore it. ?

41. How can we optimize or increase the speed of a mysql select query?

42. How many ways can we get the value of current session id?

43. How can we destroy the session, how can we unset the variable of a session?

44. How can we destroy the cookie?

45. How many ways we can pass the variable through the navigation between the pages?

46. What is the difference between ereg_replace() and eregi_replace()?

47. What are the different functions in sorting an array?

48. How can we know the count/number of elements of an array?

49. What is the php predefined variable that tells the What types of images that php supports?

50. How can I know that a variable is a number or not using a JavaScript?

51. List out some tools through which we can draw E-R diagrams for mysql.

52. How can I retrieve values from one database server and store them in other database server using php?

53. List out the predefined classes in php?

54. How can I make a script that can be bilanguage (supports English, German)?

55. What are the difference between abstract class and interface?

56. How can we send mail-using JavaScript?

57. How can we repair a mysql table?

58. What are the advantages of stored procedures, triggers, indexes?

59. What is the maximum length of a table name, database name, and fieldname in mysql?

60. How many values can the SET function of mysql takes?

61. What are the other commands to know the structure of table using mysql commands except explain command?

62. How many tables will create when we create table, what are they?

63. What is the purpose of the following files having extensions 1) frm 2) MYD 3) MYI. What these files contains?

64. What is maximum size of a database in mysql?

65. Give the syntax of Grant and Revoke commands?

66. Explain Normalization concept?

67. How can we find the number of rows in a table using mysql?

68. How can we find the number of rows in a result set using php?

69. How many ways we can we find the current date using mysql?

70. What are the advantages and disadvantages of CASCADE STYLE SHEETS?

71. What type of inheritance that php supports?

72. How can increase the performance of mysql select query?

The structure of table view buyers is as follows

+—————-+————-+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+—————-+————-+——+—–+———+—————-+
| user_pri_id | int(15) | | PRI | NULL | auto_increment |
| userid | varchar(10) | YES | | NULL | |
+—————-+————-+——+—–+———+—————-+

the value of user_pri_id the last row 2345 then What will happen in the following conditions

Condition1: Delete all the rows and insert another row then What is the starting value for this auto incremented field user_pri_id ,
Condition2: Delete the last row(having the field value 2345) and insert another row then What is the value for this auto incremented field user_pri_id

73. What are the advantages/disadvantages of mysql and php?

74. What is the difference between GROUP BY and ORDER BY in Sql?

75. What is the difference between char and varchar data types?

76. What is the functionality of md5 function in php?

77. How can I load data from a text file into a table?

78. How can we know the number of days between two given dates using mysql?

79. How can we know the number of days between two given dates using php?

80. How can we change the name of a column of a table?

81. How can we change the name and data type of a column of a table?

82. What are the differences between drop a table and truncate a table?

83. When you want to show some part of a text displayed on an HTML page in red font color, what different possibilities are there to do this? What are the advantages/disadvantages of these methods?

84. When viewing an HTML page in a Browser, the Browser often keeps this page in its cache. What can be possible advantages/disadvantages of page caching? How can you prevent caching of a certain page (please give several alternate solutions)?

85. What are the different methods of passing data or information between two calls of a web page? What are the advantages/disadvantages of these methods?

86. An Apache web server is running on a Linux system. Suddenly, the web server delivers the pages very slow. How could you find out possible reasons for that (when using system commands, please specify their names)?

87. What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?

88. Please give a regular expression (preferably Perl/PREG style), which can be used to identify the URL from within a HTML link tag. Example: The regular expression should match the tag <A HREF=”http://www.yoursite.com/”> and give the URL (”http://www.yoursite.com /”) as a return result. Tags should also be matched if they contain other attributes than the HREF attribute.

89. A select query over a large table runs very slow because of the growing number of entries in that table. What different measures could be taken to improve speed?

90. A company wants to store their invoices in a database. They already have their customers and articles in that database. Both customer and article are each identified by an unique integer value. Please create the SQL statements for creating the necessary table(s) for storing the invoices in a MySQL database. An invoice should hold information like invoice number, customer, date, article(s) and quantity etc.

91. For the database from the previous question, please give an SQL query which returns the invoice number of all invoices which contain the article with the number “1234″. The query should be able to run under a MySQL 4.0 database.

92. How would you backup and restore a big MySQL database? What are the advantages of the approach which you have taken over the others?

93. Create a PHP web script with the following attributes: on start, three HTML form elements are shown: an string input field, a checkbox field, a dropdown/pull down list with 5 elements and a submit button. On submission, the form should be redisplayed (while remaining all options/inputs as the user has selected/entered them). Additionally, the selections/inputs of the user should be displayed in text. Please solve this without the use of any external libraries.

94. What is meant by MIME?

95. What is meant by PEAR in php?

96. How can I use the COM components in php?

97. How can I load the dll’s dynamically?

98. How many ways we can give the output to a browser?

99. How can we know that a session is started or not?

100. What is the default session time in php and how can I change it?

101. What changes I have to done in php.ini file for file uploading?

102. What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

103. How can I set a cron and how can i execute it in Unix, Linux, and windows?

104. Steps for the payment gateway processing?

105. How many ways I can register the variables into session?

106. Explain different types of errors in php (i.e. arguments in errorreporting function)?

107. How many ways I can redirect a php page?

108. List out different arguments in php header function?

109. What type of headers have to add in the mail function in which file a attached?

110. What is the difference between <?php and <? And which can be preferable

111. What are the differences between php3 and php4 versions?

112. What are the differences between include() and include_once() functions?

113. Describe the importance of DABA BASE ABSTRACTION LAYERS in php and database connection?

114. Explain mysql optimization?

115. What is the difference between using copy() and move() function in php file uploading?

116. What is the difference between Reply-to and Return-path in the headers of a mail function?

117. Explain about Type Juggling in php?

118. How can I get the only name of the current executing file?

119. How can I embed a java programme in php file and what changes have to be done in php.ini file?

120. How can I find what type of images that the php version supports?

121. The table tbl_sites contains the following data.

—————————————————–
Userid sitename country
——————————————————
1 guptaanil.com india
2 phpprogrammer andhra
3 php.net usa
4 phptalk.com germany
5 mysql.com usa
6 guptaanil.com canada
7 phpbuddy.com pakistan
8. phptalk.com austria
9. phpfreaks.com sourthafrica
10. phpsupport.net russia
11. guptaanil.com australia
12. guptaanil.com nepal
13. phptalk.com italy

Write a select query that will displayed the duplicated site name and how many times it is duplicated?

Best of Luck!!


Zend Studio for Eclipse 6.1

October 17, 2008 – 11:06 pm


I have downloaded new Zend Studio for Eclipse 6.1 and developing web application with that.Its quite nice and improved tool with many good features.

- Editor and File Management Features
- Code Generation
- JavaScript Support
- HTML Support
- Source Control
- Refactoring
- PHPUnit Testing Support
- Debugging
- Deployment Support for Remote Systems
- SQL / Database Support
- Miscellaneous
- Zend Platform Integration
- Zend Framework Integration
- Other Integration
- Zend Studio 5.5 Migration
- Installation / Documentation / Support

For detailed feature list : http://www.zend.com/en/products/studio/features

Download : http://www.zend.com/en/products/studio/downloads


HTML - Multiple selection box - Javascript

October 5, 2008 – 2:26 am


I was trying to find some javascript which allow me to select all the items in multiple selection box in html.

Finally I have created this.


function selectAll(fieldName)
{
	var fieldObj = document.getElementById(fieldName);
	for (var i=0; i < fieldObj.options.length; i++)
	{
		fieldObj.options[i].selected = true;

	}
}

function selectNone(fieldName)
{
	var fieldObj = document.getElementById(fieldName);
	for (var i=0; i < fieldObj.options.length; i++)
	{
		fieldObj.options[i].selected = false;

	}
}

Its working fine!


Version Control System

July 30, 2008 – 5:12 am


Version Control System is very popular now a days and It should be as there are lots many problems that has been resolved that we were facing during the development.

Version Control System (also known as Revision control , source control or (source) code management (SCM)) is the management of multiple revisions of the same unit of information. It is most commonly used in engineering and software development to manage ongoing development of digital documents like application source code, art resources such as blueprints or electronic models, and other projects that may be worked on by a team of people. Changes to these documents are usually identified by incrementing an associated number or letter code, termed the “revision number”, “revision level”, or simply “revision” and associated historically with the person making the change. A simple form of revision control, for example, has the initial issue of a drawing assigned the revision number “1″. When the first change is made, the revision number is incremented to “2″ and so on.

Please check the small presentation on Version Control System


What is Web 2.0?

July 22, 2008 – 10:39 am


I took a session on web 2.0 at my office in our MM (Monday Meeting). I covered following topics in it.

  • General concept of Web 1.0
  • Web 2.0
  • Cool web 2.0 applications.
  • Core Web 2.0 Technologies.
  • What’s next (Web 3.0)?

(tags: web 2.0)


Only one …atleast one…

July 20, 2008 – 5:26 am


It was again a usual morning in OPD hall and Parthiv was almost fighting with the Doctor. He was saying “God has given a pair to everyone, I want Only One …atleast One…!!! Doctor was humble enough to council him, He said “Don’t get frustrated young man , Now you will be first to get donation as you are at the top of the list and the day is not far when you will not just fight with me but will also be able to visualize me”.

Yes Parthiv was blind and he was asking for his turn to see the world, so it was a routine for him and Doctor too to have debate on Parthiv’s turn .

Again Doctor won the debate and Parthiv had to leave with deep hope in heart and a stick with white and red colors.Color this word was a cruel joke for him as it was all black in his life till today.

He often said his mother when counseling her “Baa! do not get upset I’ll fight with situation , I’ll fight with my destiny and let my journey start with Black but it will end up with white and will see all the colors in between.”

He was confident that people are aware nowadays about Eye donation and as there is no harm in Eye donation he will get Eye donation soon.He was just not the superstitious person.But he saw efforts all around him.Red Cross society , NGO’s everyone were trying their level best.People and specially youth is aware enough about Eye donation.In fact people these days prepare a will for eye donation.But the only problem is when a death happens the relatives and family members are not in set of mind to remember about donating eyes.Also few myths are there like donation doesn’t reach to needful person or people with cataract(motiya bimb) they can’t donate,even few think that if they have specs they can’t donate eyes etc… but these are all myths.Even Parthiv communicated to people whenever he got chance.He kept telling everyone that once someone dies eyes can be donated within six hours in normal circumstances and even if its late and if eyes can’t be planted those can be very useful for medical research.

Once in such meeting an old man blamed Parthiv that he was selfish and he is marketing for himself.The old man added that he would never allow anyone to touch anybody’s eyes as the dead body would look scary without eyes on face and may be blood coming out.Parthiv was really hurt to hear that.He told the old man with humid eyes that he was the best person to know what are sufferings of a human being without eyes and that was the reason behind his efforts . He added that” Yes , I want eyes ,and I’m working for myself, but person like him (old man) is not helping anyone by spreading wrong message.The real thing is When a doctor is accepting eyes from a body ,only a part of eye is taken so face or eye remains same and not even a drop of blood comes out from an eye.” The old man and the other public were embarrassed of their behavior and the old man apologized with promise to donate his eyes. But that was the last time Parthiv appealed in public.

He stopped his efforts as he didn’t wanted his efforts to be rewarded with same words again.But he didn’t gave up his hopes of getting eye/s.

He kept going to Doctor for finding the lucky day of his life but may be due to myths or whatever reason he was not getting the donor….day were converted into months and months into years.Parthiv was feeling frustrated.As frustrated as standing in a long long queue for admission or standing in a queue for getting visa of USA.May be more frustrated as he didn’t wanted to see USA but at least wanted to see himself.

He wanted to see to see his parents who brought him to this world which was only possible through hanging photographs as his parents too were died now.All went along with same color Black….

The only thing which was white in his life was his hairs now!!! He turned to 58 now.The official age of retirement.He himself declared him the “Sr.Citizen” and stopped even going to hospital. He accepted the truth that may be the Black color suits his life the most.
But the God thought otherwise… :)

Yes he got the donor !!!!

He was called from the hospital and was told that the next day the operation was planned for planting ONE EYE.And he would be having sight to see the beautiful world.Even at this age he was happy.He was crying with Joy.

That night he didn’t sleep for a minute.And rightly so..It was the day he was always looking for.
He woke up early and prepared himself.He called his neighbors and friends and asked them to keep all the colors in front of him when he comes back from hospital.He asked for peacock feather as her mother used to tell him that it has so many beautiful colors.

He started the journey of his life which was merely of one and half KM.He heard voice of a child and thought by himself “Yes I’ll see a baby once I’ll have eyes .that would be a great feeling”.He thought about thousands things ,and why not ? At last all his prayers were listened.
He still thought that something is missing and it sparked in his mind and he bought a mirror to watch himself first.

With all this joy and tremendous nervousness he entered the hospital.He was greeted by the staff of the hospital.He was asked to sit in the same OPD hall.
After half an hour all the formalities were completed.He was asked to wear the operation Apron.
It was just a matter of time and he was going to be King of The World.He remembered “Saibaba” and started moving towards changing room with help of one nurse.

The environment was not new for him.Same noise of stretchers,ward boys,nurses ,smell of medicines …he was moving across these all.And then he heard something different.He didn’t noticed it first but as he concentrated on voice he found that it was someone who was having quarrel with someone. He was more attracted to the voice when he got something which he used to say years back. Those words were “I want Only One …atleast One…!!!”. Parthiv inquired about the same to the nurse.He came to know that there was a young man and was inquiring about his turn to find a donor for himself and Parthiv stopped without any reason. It was a strange feeling for him.Why he was stopping? What he wanted to do? No one had answer!!!

It was like the entire history was getting repeated.He counted something and counted again.He talked with himself and said “Yes I’ve got few but This young fellow has many”. Yes he was counting years remaining in their respective lives.

With a resigning and heavy hearted smile he called that fellow.He ran his hand on the mirror which was wet with couple of drops of tears.

He gifted that mirror the young man!!!!!!

If you have eyes then I am dam sure that now it is full of tears…!!!

This story is written by one of my best friend “Jaldeep Upadhyay”.

Whoever has read this has decided to donate eyes, what about you???

Join this group : Donate Eyes


Creative Websites

July 19, 2008 – 9:32 am


Hi,

Today I came through a very wonderful post of one of my friend Gaurav Vakhariya. He has listed some very creative websites and these are here…

Enjoy your free time by visiting these sites….

http://www.smashingmagazine.com/2007/07/17/exploring-design-outstanding-start-pages/

http://leoburnett.ca/

http://www.capitalcomm.com.my/

http://www.mhq.nl/

http://www.hellosweetie.co.uk/

http://lab.mathieu-badimon.com/

http://www.vault49.com/

http://www.pr0jects.com/portfolio/

http://www.dontclick.it/

Thanks Gaurav.


Launched my own website

July 15, 2008 – 11:01 am


Today is the day when I registered my own domain (www.guptaanil.com) .

I was thinking to have my own website since long so that I can share my knowledge with the community and friends (that’s you) and I did it…!!!!

Today I am happy to launch this site.

Please keep in touch with the site to get updated information about ( Anil Gupta ) and also I will pass your time with some new information.

See you soon.