In this article, we provide PHP Interview Questions which you can use to crack any level of php interview. Feel free to ask any question in questionbank.
Question # 41) What is a lambda function in PHP?
Answer # To sum up, a lambda function is an anonymous PHP function that can be stored in a variable and passed as an argument to other functions or methods. A closure is a lambda function that is aware of its surrounding context.
PHP Interview Questions And Answers
Question # 42) What is overriding in PHP?
Answer # Overloading is defining functions that have similar signatures, yet have different parameters. Overriding is only pertinent to derived classes, where the parent class has defined a method and the derived class wishes to override that method. In PHP, you can only overload methods using the magic method __call.
Question # 43) What is encapsulation in PHP?
Answer # Encapsulation is an OOP (Object Oriented Programming) concept in PHP. Wrapping some data in single unit is called Encapsulation. Second advantage of encapsulation is you can make the class read only or write only by providing setter or getter method. Capsule is best example of Encapsulation.
PHP Interview Questions And Answers
Question # 44) What is boolean in PHP?
Answer # PHP Booleans. A Boolean value is one that is in either of two states. They are known as True or False values, in programming. True is usually given a value of 1, and False is given a value of zero.
Question # 45) What is the use of Print_r function in PHP?
Answer # prinf : It is a function which takes atleast one string and format style and returns length of output string. print_r() is used for printing the array in human readable format. they both are language constructs. echo returns void and print returns 1.
Question # 46) What is the use of the anonymous function in PHP?
Answer # Anonymous functions, also known as closures, allow the creation of functions which have no specified name. They are most useful as the value of callback parameters, but they have many other uses. Anonymous functions are implemented using the Closure class.
PHP Interview Questions And Answers
Question # 47) What is the polymorphism in PHP?
Answer # Polymorphism is a long word for a very simple concept. Polymorphism describes a pattern in object oriented programming in which classes have different functionality while sharing a common interface.
Question # 48) What is the use of the magic function in PHP?
Answer # PHP provides a number of ‘magic’ methods that allow you to do some pretty neat tricks in object oriented programming. These methods, identified by a two underscore prefix (__), function as interceptors that are automatically called when certain conditions are met.
PHP Interview Questions And Answers
Question # 49) What is the use of return in PHP?
Answer # (PHP 4, PHP 5, PHP 7) return returns program control to the calling module. Execution resumes at the expression following the called module’s invocation. If called from within a function, the return statement immediately ends execution of the current function, and returns its argument as the value of the function call.
Question # 50) What is the use of die in PHP?
Answer # The die() function prints a message and exits the current script. This function is an alias of the exit() function.
PHP Developer Interview Questions
Question # 51) What is an array in PHP?
Answer # PHP Arrays – An array is a data structure that stores one or more similar type of values in a single value. For example if you want to store 100 numbers then instead of defining 100 variables its easy to define an array of 100 length.
Question # 52) How to write the comment in php?
Answer # Similiar to the HTML comment, the multi-line PHP comment can be used to comment out large blocks of code or writing multiple line comments. The multiple line PHP comment begins with †/* †and ends with †*/ “.
PHP Interview Questions And Answers
Question # 53) What is the difference between $message and $$message in PHP?
Answer # They are both variables. But $message is a variable with a fixed name. $$message is a variable who’s name is stored in $message. For example, if $message contains “varâ€, $$message is the same as $var.
Question # 54) What is the difference between require and include in PHP?
Answer # Require and include functions does the same task i.e. includes and evaluates specified file, but the difference is require will cause a fatal error when the specified file location is invalid or for any error where as include will generate a warning and continue the code execution.
PHP Interview Questions And Answers For 3 Year Experience
Question # 55) What are the different types of errors in PHP?
Answer # There are four types of errors in PHP.
Warning errors
Notice errors
Fatal errors
Parse errors
Question # 56) PHP Error Constants and their descriptions
Answer #
E_ERROR: A fatal error that causes script termination
E_WARNING: Run-time warning that does not cause script termination
E_PARSE: Compile time parse error
E_NOTICE: Run time notice caused due to error in code
E_CORE_ERROR: Fatal errors that occur during PHP’s initial startup (installation)
E_CORE_WARNING: Warnings that occur during PHP’s initial startup
E_COMPILE_ERROR: Fatal compile-time errors indication problem with script
E_USER_ERROR: User-generated error message
E_USER_WARNING: User-generated warning message
E_USER_NOTICE: User-generated notice message
E_STRICT: Run-time notices
E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error
E_ALL: Catches all errors and warnings
E_DEPRECATED
E_USER_DEPRICATED
Question # 57) What is the use of Include_once in PHP?
Answer # The include_once statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include statement, with the only difference being that if the code from a file has already been included, it will not be included again, and include_once returns TRUE .
PHP Interview Questions And Answers
Question # 58) What is Exception Handling in PHP?
Answer # With PHP 5 came to a new object oriented way of dealing with errors. Exception handling is used to change the normal flow of the code execution if a specified error (exceptional) condition occurs. This condition is called an exception.
Question # 59) Why post method is used in PHP?
Answer # GET can’t be used to send binary data, like images or word documents, to the server. The data sent by GET method can be accessed using QUERY_STRING environment variable. The PHP provides $_GET associative array to access all the sent information using GET method. The POST method transfers information via HTTP headers.
PHP Interview Questions And Answers
Question # 60) What is the use of post in PHP?
Answer # When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named “welcome.phpâ€. The form data is sent with the HTTP POST method. To display the submitted data you could simply echo all the variables.
Senior PHP Developer Interview Questions And Answers
Question # 61) What is the difference between require_once and require in PHP?
Answer # require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example.
Question # 62) What is the use of die in PHP?
Answer # The die() function prints a message and exits the current script. This function is an alias of the exit() function.
Question # 63) How do you debug PHP?
Answer # To run a debugging session: Start the ide and open the file that contains the source code that you want to debug. Set a breakpoint at each line where you want the debugger to pause. To set a breakpoint, place the cursor at the beginning of a line and press Ctrl-F8/⌘-F8 or choose Debug > Toggle Line Breakpoint.
PHP Interview Questions And Answers
Question # 64) What is the meaning of xdebug?
Answer # Xdebug is a PHP extension which provides debugging and profiling capabilities. It uses the DBGp debugging protocol.
Question # 65) What is Chrome logger?
Answer # Chrome Logger is a Google Chrome extension for debugging server side applications in the Chrome console. Most languages include their own logging capabilities, but sometimes it is easier to see your logs right in the browser. Chrome Logger used to be known as ChromePHP.
PHP Developer Interview Questions And Answers For Experienced Candidates
Question # 66) What is the Phpstorm?
Answer # JetBrains PhpStorm is a commercial, cross-platform IDE for PHP built on JetBrains’ IntelliJ IDEA platform. PhpStorm provides an editor for PHP, HTML and JavaScript with on-the-fly code analysis, error prevention and automated refactorings for PHP and JavaScript code.
PHP Interview Questions And Answers
Question # 67) What is Zend Studio for?
Answer # Zend Studio is a commercial, proprietary integrated development environment (IDE) for PHP developed by Zend Technologies, based on the PHP Development Tools (PDT) plugin for the Eclipse platform (the PDT project is led by Zend). … Zend Studio is also integrated with Zend Framework.
Question # 68) What is urlencode and urldecode in php?
Answer # urlencode(string) — This PHP function is encodes a string to be used in a query part of a URL. URL encoding is used when placing text in a query string to avoid it being confused with the URL itself. It is normally used when the browser sends form data to a web server.
urldecode(string) – This PHP function id decodes any encoded value in the given string.
Question # 69) What is LAMP in PHP?
Answer # LAMP is a combination of Linux, Apache, MySQL and PHP.
PHP Interview Questions And Answers
Question # 70) What is the maximum size of a database in mysql?
Answer #
Operating System File-size Limit
Win32 w/ FAT/FAT32 2GB/4GB
Win32 w/ NTFS 2TB (possibly larger)
Linux 2.2-Intel 32-bit 2GB (LFS: 4GB)
Linux 2.4+(using ext3 file system) 4TB
Solaris 9/10 16TB
MacOS X w/ HFS+ 2TB
NetWare w/NSS file system 8TB
PHP Programming Questions
Question # 71) What is the maximum size of a table in MySQL?
Answer # You are using a MyISAM table and the space required for the table exceeds what is permitted by the internal pointer size. MyISAM permits data and index files to grow up to 256TB by default, but this limit can be changed up to the maximum permissible size of 65,536TB (2567 − 1 bytes).
Question # 72) What is the capacity of MySQL database?
Answer # Database Storage Capacity. MySQL is limited by the largest file size that the operating system you run it on can handle (between 4Gb and 256Tb depending on the O/S). With the innoDB table format you can even span multiple files with one table allowing for tables in the database of up to 64Tb.
PHP Interview Questions And Answers
Question # 73) How many records can be stored in MySQL table?
Answer # In InnoDB, with a limit on table size of 64 terabytes and a MySQL row-size limit of 65,535 there can be 1,073,741,824 rows. That would be minimum number of records utilizing maximum row-size limit. However, more records can be added if the row size is smaller.
Question # 74) How many columns can be added in a table in mysql?
Answer # MySQL 5.0 Column Count Limits: There is a hard limit of 4096 columns per table, but the effective maximum may be less for a given table. The exact limit depends on several interacting factors. Every table (regardless of storage engine) has a maximum row size of 65,535 bytes.
PHP Interview Questions And Answers
Question # 75) What is varchar mysql?
Answer # Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.
PHP Programming Interview Questions
Question # 76) How big is varchar Max?
Answer # n defines the string length and can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size is the actual length of the data entered + 2 bytes. The ISO synonyms for varchar are charvarying or charactervarying.
Question # 77) Why triggers are used in mysql?
Answer # The MySQL trigger is a database object that is associated with a table. It will be activated when a defined action is executed for the table. The trigger can be executed when you run one of the following MySQL statements on the table: INSERT, UPDATE and DELETE and it can be invoked before or after the event.
PHP Interview Questions And Answers
Question # 78) How big is Nvarchar Max?
Answer # In Nvarchar “n†defines the string length and can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size, in bytes, is two times the actual length of data entered + 2 bytes. The ISO synonyms for nvarchar are national char varying and national character varying.
Question # 79) Why delimiter is used in mysql?
Answer # By default, mysql itself recognizes the semicolon as a statement delimiter, so you must redefine the delimiter temporarily to cause mysql to pass the entire stored program definition to the server. To redefine the mysql delimiter, use the delimiter command.
Question # 80) What is a stored procedure in mysql?
Answer # A procedure (often called a stored procedure) is a subroutine like a subprogram in a regular computing language, stored in database. A procedure has a name, a parameter list, and SQL statement(s). All most all relational database system supports stored procedure, MySQL 5 introduce stored procedure.
If you have any questions, or you think you can help others by answering the questions asked then must go to our questions bank section.