You should always close a file in PHP using the fclose() function after you're done with it.

  • TRUE
  • FALSE
  • nan
  • nan
In PHP, it is good practice to always close a file using the fclose() function after you have finished working with it. This ensures that the file resources are released, memory is freed up, and it helps prevent resource leaks.

What are some common practices in PHP when dealing with JSON data?

  • Validating and sanitizing JSON data received from external sources
  • Handling JSON decoding errors and exceptions
  • Properly encoding and decoding JSON data using json_encode() and json_decode()
  • All of the above
When dealing with JSON data in PHP, some common practices include validating and sanitizing JSON data received from external sources, handling JSON decoding errors and exceptions, and properly encoding and decoding JSON data using json_encode() and json_decode() functions. The correct option is "All of the above" as all the mentioned practices are common and important when working with JSON data in PHP. For more details, refer to the PHP documentation on working with JSON: http://php.net/manual/en/book.json.php

What are some commonly used miscellaneous functions in PHP?

  • strlen(), strtotime(), file_exists()
  • array_merge(), json_encode(), htmlspecialchars()
  • trim(), substr(), strtolower()
  • All of the above
PHP provides a wide range of miscellaneous functions for various tasks. Some commonly used miscellaneous functions in PHP include strlen() (to get the length of a string), strtotime() (to convert a date/time string to a Unix timestamp), and file_exists() (to check if a file or directory exists). Other frequently used functions include array_merge(), json_encode(), htmlspecialchars(), trim(), substr(), strtolower(), and many more. These functions offer functionality for string manipulation, file handling, array operations, and other common tasks in PHP programming.

What PHP superglobal array holds the session variables?

  • $_SESSION
  • $_COOKIE
  • $_REQUEST
  • $_SERVER
The $_SESSION superglobal array holds the session variables in PHP. It allows you to store and access data across multiple pages or requests within the same session. The values stored in $_SESSION are specific to each individual user session and can be used to maintain user-specific data throughout the browsing session. Additional information can be found at: http://php.net/manual/en/reserved.variables.session.php

The $_SESSION superglobal array in PHP holds the session variables.

  • TRUE
  • FALSE
  • nan
  • nan
The $_SESSION superglobal array in PHP holds the session variables. It allows you to store and retrieve data across multiple pages or requests within the same session. The values stored in $_SESSION are specific to each individual user session. For further information, visit: http://php.net/manual/en/reserved.variables.session.php

Regular Expressions in PHP are case-sensitive.

  • TRUE
  • FALSE
The statement is true. Regular Expressions in PHP are case-sensitive by default. This means that when defining patterns or searching for matches, the case of the characters matters. For example, if a pattern specifies "abc", it will only match "abc" in the string and not "ABC" or "Abc". If case-insensitive matching is required, the appropriate modifier can be added to the Regular Expression pattern. Learn more: https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php

A constant of a PHP class can be accessed using the class name followed by the scope resolution operator (::) and the constant name.

  • TRUE
  • FALSE
  • nan
  • nan
A constant of a PHP class can indeed be accessed using the class name followed by the scope resolution operator :: and the constant name. For example: ClassName::CONSTANT_NAME This allows you to directly reference the value of a constant defined within a class without the need for object instantiation. The scope resolution operator :: is used to access static members, including constants, of a class. To learn more, visit: http://php.net/manual/en/language.oop5.constants.php

What is an abstract class in the context of PHP OOP?

  • A class that cannot be instantiated directly
  • A class that can be instantiated directly
  • A class that can only have static methods
  • A class that can only have public properties
In PHP OOP, an abstract class is a class that cannot be instantiated directly. It serves as a blueprint for other classes and provides common functionality and structure that can be inherited by its child classes. An abstract class can have abstract methods, which are declared but not implemented in the abstract class itself. Child classes that inherit from the abstract class must implement the abstract methods. For more details, visit: http://php.net/manual/en/language.oop5.abstract.php

Once a constant is defined in PHP, it ______ be changed during the execution of the script.

  • Cannot
  • Can
  • Must
  • May
Once a constant is defined in PHP, it cannot be changed during the execution of the script. Constants are intended to store fixed values that remain constant throughout the execution of the script. They are not meant to be modified or redefined once defined. Any attempt to change a constant's value will result in an error. This behavior ensures the integrity and consistency of the constant values throughout the script's execution. Learn more: https://www.php.net/manual/en/language.constants.php

You are writing a PHP script and you need to check if a variable contains a numeric value. How would you do this?

  • is_numeric($variable)
  • is_string($variable)
  • is_integer($variable)
  • is_bool($variable)
To check if a variable contains a numeric value in PHP, you can use the is_numeric() function. The is_numeric() function checks if a variable can be evaluated as a number, whether it is an integer, float, or a numeric string. It returns true if the variable is numeric and false otherwise. This function is useful when you need to validate the numeric nature of a variable. Learn more: https://www.php.net/manual/en/function.is-numeric.php