PHP is a widely used open-source programming language especially suited for creating dynamic websites and mobile API’s. So, if you are planning to start your career in PHP and you wish to know the skills related to it, now is the precise time to dive in. The article is sub divided into 2 parts:
a) basic questions
b) advance questions
1)What is meant by PHP?
Answer: PHP is a web language based on scripts that allow developers to dynamically create generated web pages.
2)What does the initials of PHP stands for?
Answer: PHP means in PHP: Hypertext Pre-processor.
3)Which programming language does PHP be similar to?
Answer: PHP syntax resembles Perl and C
4) What does PEAR stand for?
Answer: PEAR means “PHP Extension and Application Repository”. It extends PHP and provides a higher level of programming for web developers.
5) Is multiple inheritance supported in PHP?
Answer: PHP supports only single inheritance; it means that a class can be extended from only one single class using the keyword ‘extended’.
6) What is the meaning of a final class and a final method?
Answer: The ‘final’ is introduced in PHP5. Final class means that this class cannot be extended and a final method cannot be overridden.
7) How is the comparison of objects done in PHP?
Answer: We use the operator ‘==’ to test is two objects are instanced from the same class and have same attributes and equal values. We can test if two objects are referring to the same instance of the same class by the use of the identity operator ‘===’.
8) How can PHP and HTML interact?
Answer: PHP is possible to generate HTML through PHP scripts, and it is possible to pass pieces of information from HTML to PHP.
9) What type of operation is needed when passing values through a form or an URL?
Answer: If we would like to pass values through a form or an URL, then we need to encode and to decode them using htmlspecialchars() and urlencode().
12) How can we determine whether a variable is set?
Answer: The Boolean function isset determines if a variable is set and is not NULL.
13) What is the difference between the functions strstr() and stristr()?
Answer: The string function strstr(string allString, string occ) returns part of allString from the first occurrence of occ to the end of allString. This function is case-sensitive. stristr() is identical to strstr() except that it is case insensitive.
14) what is the difference between for and foreach?
Answer: The for is expressed as follows:
for (expr1; expr2; expr3)
statement: The first expression is executed once at the beginning. In each iteration, expr2 is evaluated. If it is TRUE, the loop continues, and the statements inside for are executed. If it evaluates to FALSE, the execution of the loop ends. expr3 is tested at the end of each iteration. However, foreach provides an easy way to iterate over arrays, and it is only used with arrays and objects.
15) Is it possible to submit a form with a dedicated button?
Answer: It is possible to use the document.form.submit() function to submit the form. For example: <input type=button value=”SUBMIT” onClick=”document.form.submit()”>
16) What is the difference between ereg_replace() and eregi_replace()?
Answer: The function eregi_replace() is identical to the function ereg_replace() except that it ignores case distinction when matching alphabetic characters.
17) Is it possible to protect special characters in a query string?
Answer: Yes, we use the urlencode() function to be able to protect special characters.
18) What are the three classes of errors that can occur in PHP?
Answer: The three basic classes of errors are notices (non-critical), warnings (serious errors) and fatal errors (critical errors).
19) What is the difference between characters \034 and \x34?
Answer: \034 is octal 34 and \x34 is hex 34.
20) How can we pass the variable through the navigation between the pages?
Answer: It is possible to pass the variables between the PHP pages using sessions, cookies or hidden form fields.
21) Is it possible to extend the execution time of a PHP script?
Answer: The use of the set_time_limit(int seconds) enables us to extend the execution time of a PHP script. The default limit is 30 seconds.
22) Is it possible to destroy a cookie?
Answer: Yes, it is possible by setting the cookie with a past expiration time.
23) What is the default session time in PHP?
Answer: The default session time in php is until the closing of the browser.
24) Is it possible to use COM component in PHP?
Answer: Yes, it’s possible to integrate (Distributed) Component Object Model components ((D)COM) in PHP scripts which is provided as a framework.
25) Explain whether it is possible to share a single instance of a Memcache between multiple PHP projects?
Answer: Yes, it is possible to share a single instance of Memcache between multiple projects. Memcache is a memory store space, and you can run memcache on one or more servers. You can also configure your client to speak to a particular set of instances. So, you can run two different Memcache processes on the same host and yet they are completely independent. Unless, if you have partitioned your data, then it becomes necessary to know from which instance to get the data from or to put into.
26) Explain how you can update Memcached when you make changes to PHP?
Answer: When PHP changes you can update Memcached by
Clearing the Cache proactively: Clearing the cache when an insert or update is made
Resetting the Cache: It is similar to the first method but rather than just deleting the keys and waiting for the next request for the data to refresh the cache, reset the values after the insert or update.
27) What is the difference between runtime exception and compile time exception?
Answer: An exception that occurs at compile time is called a checked exception. This exception cannot be ignored and must be handled carefully. For example, if you use FileReader class to read data from the file and the file specified in class constructor does not exist, then a FileNotFoundException occurs and you will have to manage that exception. For the purpose, you will have to write the code in a try-catch block and handle the exception. On the other hand, an exception that occurs at runtime is called unchecked-exception.
For Accenture HR interview questions and answers for Freshers. Click Here