Which function gives us the number of affected entries by a query?

  • The mysqli_affected_rows() function
  • The mysqli_num_rows() function
  • The mysqli_query_count() function
  • The mysqli_result_count() function
The mysqli_affected_rows() function is used to retrieve the number of affected rows by a query in PHP. It returns the number of rows affected by the last INSERT, UPDATE, DELETE, or REPLACE statement executed with the MySQLi connection. It's important to note that this function only works with the MySQLi extension in PHP. If you are using the deprecated MySQL extension or the PDO extension, you need to use the respective functions provided by those extensions to retrieve the number of affected rows.

Which of the following are valid PHP operators?

  • Addition (+)
  • Concatenation (.)
  • Assignment (=)
  • All of the above
PHP supports a wide range of operators, including arithmetic operators like addition (+), assignment operators like equals (=), and string operators like concatenation (.). These allow you to perform operations on variables and values. Learn more: https://www.php.net/manual/en/language.operators.php

If you want to read a file in PHP, you can use the fread() function where the first argument is the file pointer and the second argument is the maximum number of ______ to read.

  • lines
  • characters
  • words
  • bytes
The fread() function in PHP is used to read a file. The first argument is the file pointer obtained from fopen(), and the second argument is the maximum number of bytes to read from the file.

You need to execute a block of code in your PHP script for each key-value pair in an associative array. How would you do this using a foreach loop?

  • Use the "for" loop and access the elements using their indexes
  • Use the "foreach" loop and access the elements using the "key" and "value" variables
  • Use the "while" loop and access the elements using the "current" and "next" functions
  • Use the "foreach" loop and access the elements using the "key" and "value" pairs
The correct option is: "Use the 'foreach' loop and access the elements using the 'key' and 'value' variables." In PHP, you can use the foreach loop with an associative array to iterate over each key-value pair. During each iteration, you can access the key of the current element using the 'key' variable and the corresponding value using the 'value' variable. This allows you to execute a block of code for each key-value pair in the associative array. Learn more: https://www.php.net/manual/en/control-structures.foreach.php

What are the two main string operators?

  • Concatenation and interpolation
  • Assignment and comparison
  • Increment and decrement
  • Logical and bitwise operations
The two main string operators in PHP are concatenation (using the . operator) and interpolation (using variables within double-quoted strings). They allow manipulation and combination of string values. Learn more: http://php.net/manual/en/language.operators.string.php

What are the differences between a trait and a class in PHP?

  • A trait cannot be instantiated on its own, while a class can.
  • A class can have properties and constants, while a trait cannot.
  • A class can implement multiple interfaces, while a trait cannot.
  • All of the above
There are several differences between traits and classes in PHP. A trait cannot be instantiated on its own; it needs to be included in a class. In contrast, a class can be instantiated to create objects. Additionally, a class can have its own properties and constants, while a trait cannot have its own properties directly. Moreover, a class can implement multiple interfaces, whereas a trait cannot directly implement interfaces. These distinctions highlight the different roles and purposes of traits and classes in PHP OOP.

The $_SERVER superglobal in PHP is often used to get the URL of the current page.

  • TRUE
  • FALSE
The statement is true. By using $_SERVER['REQUEST_URI'], you can retrieve the URL of the current page. The 'REQUEST_URI' key within the $_SERVER superglobal stores the path and query string of the requested URL. This information can be useful for various purposes, such as generating dynamic navigation menus, redirecting users, or capturing analytics data. Learn more: https://www.php.net/manual/en/reserved.variables.server.php

Which of the following are valid ways to define a string in PHP?

  • 'Hello World'
  • "Hello World"
  • <<
  • All of the above
All of the given options are valid ways to define a string in PHP. Strings can be defined using single quotes (''), double quotes (""), or heredoc syntax (<<

Form Handling in PHP can involve data validation.

  • TRUE
  • FALSE
The statement is true. Form Handling in PHP often involves data validation to ensure that the user-submitted data meets the required criteria or follows specific patterns. PHP provides various functions and techniques to validate form inputs, such as checking for required fields, validating email addresses, verifying passwords, and more. By performing data validation, PHP helps maintain data integrity and enhances the security of applications by preventing the processing of erroneous or malicious inputs. Learn more: https://www.php.net/manual/en/tutorial.forms.php

In PHP, an abstract class is defined using the abstract keyword.

  • TRUE
  • FALSE
  • nan
  • nan
In PHP, an abstract class is indeed defined using the abstract keyword. This keyword is placed before the class keyword and is used to indicate that the class is intended to be an abstract class. Abstract classes are meant to be inherited by other classes and cannot be instantiated directly. Abstract classes can contain abstract methods (without implementation) as well as non-abstract methods. The abstract keyword is essential for properly defining an abstract class in PHP. For more details, refer to: http://php.net/manual/en/language.oop5.abstract.php