The PHP function ________ is used to repeat a string a specified number of times.
- str_repeat()
- repeat_string()
- repeat()
- multiply_string()
The str_repeat() function in PHP is used to repeat a string a specified number of times. It's a helpful way to create repeated patterns or sequences.
In a form, what should the enctype attribute be set to for uploading files?
- text/plain
- application/json
- multipart/form-data
- application/x-www-form-urlencoded
The enctype attribute in an HTML form should be set to multipart/form-data when you want to allow file uploads. This encoding type is used for sending binary data, like files.
In a switch-case structure, the ________ keyword is used to specify the default action when no case matches.
- if
- default
- else
- break
In a switch-case structure, the default keyword specifies the action when no case matches the switch expression.
Which of the following is NOT a valid exception handling method in PHP?
- try-catch
- set_exception_handler()
- throw
- onError()
onError() is not a valid exception handling method in PHP. The correct methods are try-catch, and set_exception_handler()
The $_FILES superglobal in PHP has an array key named ________ which provides the original name of the uploaded file.
- $_FILES['file']
- $_FILES['name']
- $_FILES['original']
- $_FILES['temp_name']
In PHP, the '$_FILES' superglobal contains information about the uploaded files, and the 'name' key specifically provides the original name of the uploaded file.
An array that has named indexes instead of numeric is called a(n) ________ array.
- Associative Array
- Indexed Array
- Numeric Array
- Sequential Array
An array with named indexes is known as an Associative Array. In PHP, you can use strings as keys to access values in the array, making it very flexible.
Constants in PHP are by default ________ (case-sensitive/case-insensitive).
- case-insensitive
- uppercase-sensitive
- lowercase-sensitive
- case-sensitive
Constants in PHP are, by default, case-sensitive. This means that constant names are distinct based on their case (e.g., "CONSTANT" and "constant" are considered different).
Consider a scenario where you need to ensure that a particular piece of code only executes once, regardless of how many times a function is called. Which PHP feature or function would you utilize?
- Singleton Pattern
- Static Variable
- sleep()
- exit()
To ensure a piece of code only executes once, you can use a static variable inside a function to keep track of whether it has already been executed.
In PHP OOP, what does the term "inheritance" mean?
- Passing properties
- Extending a class
- Object duplication
- Class encapsulation
In PHP Object-Oriented Programming, "inheritance" means extending a class to create a new class with the same properties and methods as the parent class.
In a database transaction, what does the term "atomicity" refer to?
- The transaction's ability to be rolled back if an error occurs
- The transaction's ability to be divided into smaller parts
- The transaction's ability to be completed without any errors
- The transaction's ability to be scheduled concurrently
"Atomicity" in the context of a database transaction refers to its ability to be completed without any errors. It ensures that all the operations within the transaction are executed successfully, or the transaction is rolled back entirely if any part of it fails, maintaining the database's integrity.