Which of the following software stacks include PHP?
- WAMP
- MEAN
- Ruby on Rails
- Django
WAMP is a software stack for Windows that includes PHP. WAMP stands for Windows, Apache, MySQL, and PHP. Apache is the web server, MySQL is the database, and PHP is the scripting language. It's a popular choice for developers working in a Windows environment. Other software stacks like MEAN, Ruby on Rails, and Django use different programming languages. Learn more: http://www.wampserver.com/en/
How can we change the maximum size of the files to be uploaded?
- Modify php.ini configuration
- Use the ini_set() function
- Change server permissions
- It is not possible to change it
The maximum size of files to be uploaded can be changed by modifying the upload_max_filesize directive in the php.ini configuration file or by using the ini_set() function in PHP code.
In PHP, are objects passed by value or by reference?
- By value
- By reference
- Depends on the scenario
- Both options are valid
In PHP, objects are passed by value. When you assign or pass an object to a variable or a function, a copy of the object is created. Learn more: http://php.net/manual/en/language.oop5.references.php
What are some of the uses of abstract classes in PHP OOP?
- Providing common
- Defining interfaces
- Implementing traits
- All of the above
Abstract classes in PHP OOP have several uses, including providing common functionality and structure that can be inherited by child classes, defining interfaces for a group of related classes to implement, and implementing traits to share code among multiple classes. Abstract classes allow you to create a hierarchy of classes and establish a contract for the derived classes. They provide a level of abstraction and reusability in object-oriented programming. For further details, visit: http://php.net/manual/en/language.oop5.abstract.php
To delete a cookie in PHP, you can use the setcookie() function with an expiration date in the ______.
- past
- future
- present
- distant
To delete a cookie in PHP, you can use the setcookie() function and set the expiration date in the past. This causes the browser to discard the cookie, effectively deleting it. Additional information: http://php.net/manual/en/function.setcookie.php
What PHP function can be used to format a date?
- date_format()
- format_date()
- date()
- strftime()
The strftime() function can be used to format a date and time according to a specified format string. For more information, refer to: http://php.net/manual/en/function.strftime.php
You cannot modify global variables using the $GLOBALS superglobal in PHP.
- FALSE
- TRUE
The correct option is 2. You can modify global variables using the $GLOBALS superglobal in PHP. The $GLOBALS array provides references to all global variables, allowing you to retrieve their values and modify them directly. By accessing specific elements using their names as keys in the $GLOBALS array, you can update the values of global variables from anywhere within the script. However, it is generally recommended to use caution when modifying global variables, as excessive reliance on them can lead to code complexity and potential issues. It is often preferable to utilize other techniques, such as passing variables as function parameters or using object-oriented design principles, to achieve better code organization and maintainability. Learn more: https://www.php.net/manual/en/reserved.variables.globals.php
How can you encode a PHP array into a JSON object?
- json_encode()
- json_serialize()
- json_convert()
- All of the above
To encode a PHP array into a JSON object, you can use the json_encode() function. It converts a PHP value (such as an array) into its JSON representation. The other mentioned options (json_serialize(), json_convert()) are not valid PHP functions for encoding an array into a JSON object. For further details, refer to the PHP documentation on json_encode(): http://php.net/manual/en/function.json-encode.php
Which of the following are ways to access a global variable inside a function in PHP?
- Use the global keyword followed by the variable name inside the function.
- Pass the global variable as a parameter to the function.
- Access the variable directly without any special keyword or parameter passing.
- All of the above
All of the given options are valid ways to access a global variable inside a function in PHP. You can use the global keyword followed by the variable name inside the function to indicate that you want to work with the global variable. Alternatively, you can pass the global variable as a parameter to the function. Additionally, global variables can be accessed directly from within the function without any special keyword or parameter passing. Learn more: https://www.php.net/manual/en/language.variables.scope.php#language.variables.scope.global
What is the continue statement used for in PHP?
- Skipping the remaining code in the current iteration of a loop
- Resuming the next iteration of a loop
- Breaking out of a switch statement
- Terminating the execution of a function
The correct option is: "Resuming the next iteration of a loop." In PHP, the continue statement is used to skip the remaining code in the current iteration of a loop and move on to the next iteration. It is commonly used when you want to skip certain iterations based on a condition. Learn more: https://www.php.net/manual/en/control-structures.continue.php