Reference Page: PHP|Python|Perl|Ruby|MatLab

PHP Links : Learn     Interview Questions     Software IDE PHP Jobs : Indeed.com     ZipRecruiter.com     Monster.com

PHP Interview Questions - Page 1

Next Page >
Question: What are the differences between PHP and HTML?
Answer: HTML is a markup language used for creating static web pages, while PHP is a scripting language used for creating dynamic web pages. PHP can interact with databases, handle forms, generate dynamic content, and perform other server-side tasks, while HTML is mainly used for structuring web pages.

Question: What are the different data types in PHP?
Answer: PHP supports following data types:
integers, floats (floating-point numbers), strings, booleans, arrays, objects, NULL, etc.

Question: What is the difference between single quotes ('') and double quotes ("") in PHP?
Answer: In PHP, single quotes ('') indicate a literal string where variables and escape sequences are not interpreted, while double quotes ("") allow for variable interpolation and interpretation of escape sequences like '\n' and '\t'.

Question: What is the difference between '==' and '===' operators in PHP?
Answer: The '==' operator checks for equality only in terms of value, whereas the '===' operator checks for both value and data type.
So, '===' is a strict comparison operator.

Question: Can you explain the difference between include() and require() functions in PHP?
Answer: Both include() and require() are used to include files in PHP.

But the primary difference is that if the file specified in require() function is not found, it halts the script execution and throws a fatal error, whereas include() generates a warning and continues script execution.

Question: How can you prevent SQL injection attacks in PHP?
Answer: To prevent SQL injection attacks, one can use parameterized queries using PDO (PHP Data Objects) or MySQLi extension.
This helps separate SQL logic from data, making it impossible for attackers to inject malicious SQL code.

Question: Can you explain the difference between session and cookie in PHP?
Answer: A session is a way to store information (in variables) to be used across multiple pages. It's a server-side mechanism.
Cookies, on the other hand, are stored on the client's browser and are used to store user-specific information locally.

Question: What is the use of 'isset()' and 'empty()' functions in PHP?
Answer: The 'isset()' is used to determine if a variable is set and is not null, while 'empty()' is used to determine if a variable is empty, which includes zero, false, an empty string, or a variable with a value of null.

Question: Can you explain the difference between GET and POST methods in form submissions in PHP?
Answer: The GET sends form data in the URL, visible to everyone in the address bar, and has limitations on the amount of data that can be sent.
POST sends form data in the HTTP request body, which is not visible in the URL, and it's suitable for sensitive data and larger amounts of data.


Next Page >