You are writing a PHP script and you need to add the values of two variables. How would you do this using operators?

  • $sum = $var1 + $var2;
  • $sum = $var1 - $var2;
  • $sum = $var1 * $var2;
  • $sum = $var1 / $var2;
To add the values of two variables in PHP, you would use the + operator. The expression $sum = $var1 + $var2; will add the values of $var1 and $var2 and store the result in the variable $sum. The + operator is the arithmetic addition operator in PHP and is used to perform addition operations on numerical values. Learn more: https://www.php.net/manual/en/language.operators.arithmetic.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

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 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

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

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.

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/

The filter_list() function is used to get the list of all supported filters in PHP.

  • function
  • filters
  • types
  • supported
The filter_list() function is used to get the list of all supported filters in PHP. It returns an array containing the names of all available filters. Learn more at: http://php.net/manual/en/function.filter-list.php

The is_float() function in PHP checks if a variable is an integer.

  • TRUE
  • FALSE
This statement is false. The is_float() function in PHP checks if a variable is a float, not an integer. It returns true if the variable is a float (a number with a decimal point or an exponential form) and false otherwise. To check if a variable is an integer, you can use the is_int() function. Learn more: https://www.php.net/manual/en/function.is-float.php https://www.php.net/manual/en/function.is-int.php

What is the function func_num_args() used for?

  • The function func_num_args() is used to retrieve the number of arguments passed to a function in PHP.
  • The function func_num_args() is used to retrieve the number of arguments expected by a function in PHP.
  • The function func_num_args() is used to retrieve the number of arguments remaining in a function in PHP.
  • The function func_num_args() is used to retrieve the number of arguments already processed by a function in PHP.
The function func_num_args() is used to retrieve the number of arguments passed to a function in PHP. It is often used in conjunction with other functions like func_get_arg() and func_get_args() to create flexible and dynamic functions that can handle a variable number of arguments. For example, you can use func_num_args() inside a function to determine how many arguments were passed to it and then iterate over the arguments using a loop with func_get_arg() to process each argument individually. The func_num_args() function provides a convenient way to create generic functions that can adapt to different input parameters. It's important to note that func_num_args() can only be used within a user-defined function and not outside of it.

What is the $GLOBALS superglobal in PHP?

  • An array containing references to all variables that are currently defined in the global scope of the script.
  • A variable that stores global values for a PHP script.
  • A special function for accessing global variables.
  • A reserved keyword for declaring global variables.
The correct option is 1. The $GLOBALS superglobal in PHP is an associative array that contains references to all variables that are currently defined in the global scope of the script. The keys of the $GLOBALS array are the variable names, and the values are references to the corresponding variables. It provides a way to access global variables from anywhere within the script, including within functions or classes, without having to use the global keyword. By accessing the $GLOBALS superglobal, you can retrieve and manipulate global variables as needed. However, it is generally recommended to use global variables sparingly and follow good coding practices to avoid potential issues. Learn more: https://www.php.net/manual/en/reserved.variables.globals.php

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 would use the new keyword followed by the class name and parentheses. The correct option is "Using the new keyword and the class name." For more information, consult the PHP documentation on creating objects: http://php.net/manual/en/language.oop5.php