PHP Interview Questions and Answers For Experienced
1) What is the differences between $a != $b and $a !== $b?!= means inequality (TRUE if $a is not equal to $b) and !== means non-identity (TRUE if $a is not identical to $b).2) How can we determine whether a PHP variable is an instantiated object of a certain class?To be able to verify whether a PHP variable is an instantiated object of a certain class we use instanceof.3) What is the goto statement useful for? The goto statement can be placed to enable jumping inside the PHP program. The target is pointed by a label followed by a colon, and the instruction is specified as a goto statement followed by the desired target label.4) what is the difference between Exception::getMessage and Exception:: getLine?Exception::getMessage lets us getting the Exception message and Exception::getLine lets us getting the line in which the exception occurred.5) What does the expression Exception::__toString means? Exception::__toString gives the String representation of the exception.6) How is it possible to parse a configuration file? The function parse_ini_file() enables us to load in the file specified in filename and returns the settings in it in an associative array.7) How can we determine whether a variable is set? The boolean function set determines if a variable is set and is not NULL.8) What is the difference between the functions strstr() and stristr()? The string function strstr(string string, 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.9) what is the difference between for and for each? 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, each provides an easy way to iterate over arrays, and it is only used with arrays and objects.10) Is it possible to submit a form with a dedicated button? 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()”>11) What is the difference between ereg_replace() and eregi_replace()?The function eregi_replace() is identical to the function ereg_replace() except that it ignores case distinction when matching alphabetic characters.12) Is it possible to protect special characters in a query string? Yes, we use the urlencode() function to be able to protect special characters.13) What are the three classes of errors that can occur in PHP? The three basic classes of errors are notices (non-critical), warnings (serious errors) and fatal errors (critical errors).14) What is the difference between characters \034 and \x34?\034 is octal 34 and \x34 is hex 34.15) How can we pass the variable through the navigation between the pages? It is possible to pass the variables between the PHP pages using sessions, cookies or hidden form fields.16) Is it possible to extend the execution time of a PHP script? The use of the set_time_limit(in seconds) enables us to extend the execution time of a PHP script. The default limit is 30 seconds.98) Is it possible to destroy a cookie? Yes, it is possible by setting the cookie with a past expiration time.17) What is the default session time in PHP? The default session time in php is until the closing of the browser18) Is it possible to use the COM component in PHP? Yes, it’s possible to integrate (Distributed) Component Object Model components ((D)COM) in PHP scripts which is provided as a framework.19) Explain whether it is possible to share a single instance of a Memcache between multiple PHP projects? 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 it into.20) Explain how you can update Memcached when you make changes to PHP? 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.