In PHP, integers can be specified in decimal (base 10), hexadecimal (base 16), octal (base 8), and ______ (base 2) format.
- Binary
- Ternary
- Quaternary
- Octal
In PHP, integers can be specified in decimal (base 10), hexadecimal (base 16), octal (base 8), and binary (base 2) format. Decimal is the most common format, while hexadecimal is denoted by the prefix "0x", octal by the prefix "0", and binary by the prefix "0b". These different formats provide flexibility in representing and working with integers in various numeric systems. Learn more: https://www.php.net/manual/en/language.types.integer.php
What is the $_GET superglobal in PHP?
- It is a superglobal array used to retrieve data sent via an HTML form using the GET method.
- It is a superglobal array used to retrieve data sent via an HTML form using the POST method.
- It is a superglobal array used to retrieve data sent in the URL's query string using the GET method.
- It is a superglobal array used to retrieve data sent in the URL's query string using the POST method.
The $_GET superglobal in PHP is an associative array that is used to retrieve data sent in the URL's query string using the GET method. When data is sent to the server using the GET method, the values are appended to the URL as key-value pairs. The $_GET superglobal allows access to these values by using the corresponding key as an index. Learn more: https://www.php.net/manual/en/reserved.variables.get.php
How do you handle errors when creating a MySQL table using PHP?
- Check the return value of the mysqli_query() function and use error handling techniques
- Set up a custom error handling function
- Use the try-catch block with exception handling
- All of the above
When creating a MySQL table using PHP, you can handle errors by checking the return value of the mysqli_query() function. If the mysqli_query() function returns false, it indicates an error occurred during the query execution. You can then use error handling techniques such as mysqli_error() or mysqli_errno() to get detailed error information. Additionally, you can set up a custom error handling function using mysqli_set_error_handler() to define how errors should be handled. Another approach is to use the try-catch block with exception handling to catch and handle any exceptions that may occur during the table creation process. Proper error handling helps in diagnosing and resolving issues during database operations.
You have a PHP script and you need to create an object from a class. How would you do this?
- Using the new keyword and the class name
- Using the create() function and the class name
- Using the instanceof keyword and the class name
- Using the object() function and the class name
In PHP, to create an object from a class, you use the new keyword followed by the class name and parentheses. The correct option is "Using the new keyword and the class name." This instantiates an object based on the defined class. For more information, consult the PHP documentation on creating objects: http://php.net/manual/en/language.oop5.php
How can you propagate a session id?
- Using cookies
- Using URL parameters
- Using HTTP headers
- All of the above
A session id can be propagated using cookies, URL parameters, or HTTP headers. These methods allow the server to identify the client's session. Learn more: http://php.net/manual/en/intro.session.php
PHP code is enclosed in ______ and ______ tags.
- <?php, ?>
- <html>, </html>
- <php>, </php>
- <script>, </script>
PHP code is typically enclosed in <?php and ?> tags. When the PHP interpreter encounters these tags, it knows to start and stop interpreting the code between them as PHP code. This allows you to embed PHP code in an HTML file. Learn more: https://www.php.net/manual/en/language.basic-syntax.phptags.php
A common use case for the $_GET superglobal in PHP is to collect the data sent in the ______.
- URL's query string
- Request body
- Path parameters
- Headers
A common use case for the $_GET superglobal in PHP is to collect the data sent in the URL's query string. This includes parameters or values appended to the URL as key-value pairs. By using the $_GET superglobal, you can access and process this data to dynamically generate content, perform searches, or filter data based on user input. The other options, such as request body, path parameters, or headers, are not specifically associated with the $_GET superglobal. Learn more: https://www.php.net/manual/en/reserved.variables.get.php
In PHP, you can start a session using the session_start() ______.
- function
- method
- statement
- command
In PHP, you can start a session using the session_start() function. This function is called as a statement to initialize a new session or resume an existing session. It needs to be called at the beginning of your PHP script before any session variables are accessed. Refer to: http://php.net/manual/en/function.session-start.php
Which of the following are true about the for loop in PHP?
- It allows you to specify the exact number of iterations
- It always executes the code block at least once
- It can be used to iterate over an array
- It is the only loop construct available in PHP
The for loop in PHP allows you to specify the exact number of iterations you want the loop to perform. By initializing a counter variable, setting the condition for termination, and updating the counter after each iteration, you can control the flow of the loop. The for loop will execute the code block as long as the condition is true. It is a versatile loop construct that can be used to iterate over arrays, perform a specific number of iterations, or perform repetitive tasks. Learn more: https://www.php.net/manual/en/control-structures.for.php
Explain how you can update Memcached when you make changes to PHP?
- Memcached does not require updating when making changes to PHP
- Restart the Memcached server
- Clear the Memcached cache
- None of the above
To update Memcached when making changes to PHP, you need to clear the Memcached cache. This ensures that the updated data and changes are reflected in the cache. You can do this by flushing or deleting the relevant keys or by clearing the entire cache. Learn more: http://php.net/manual/en/book.memcached.php