What function do you use in PHP to execute a query against a MySQL database?

  • mysqli_query()
  • mysql_query()
  • pdo_query()
  • execute_query()
In PHP, you can use the mysqli_query() function to execute a query against a MySQL database. This function takes two parameters: the connection object and the SQL query you want to execute. The SQL query can be any valid MySQL statement, such as SELECT, INSERT, UPDATE, or DELETE. The mysqli_query() function returns a result object for successful SELECT queries or a boolean value for other types of queries. It's important to use prepared statements or proper escaping techniques to prevent SQL injection vulnerabilities when executing user-supplied data as part of the query.

What are the functions to be used to get the image's properties (size, width, and height)?

  • The functions 'getimagesize()', 'imagesx()', and 'imagesy()'
  • The functions 'imagesize()', 'imgwidth()', and 'imgheight()'
  • The functions 'size()', 'width()', and 'height()'
  • The functions 'getsize()', 'getwidth()', and 'getheight()'
To get the properties of an image such as size, width, and height in PHP, you can use the following functions: - 'getimagesize()' returns an array containing the size, width, height, and other attributes of the image. - 'imagesx()' returns the width of the image. - 'imagesy()' returns the height of the image. These functions are part of the GD library and are commonly used for image processing and manipulation in PHP.

In PHP, strings can be defined using either single quotes or double quotes.

  • TRUE
  • FALSE
This statement is true. In PHP, strings can be defined using either single quotes ('') or double quotes (""). Both single quotes and double quotes are used to delimit string literals. The choice between single quotes and double quotes depends on the specific requirements and whether variable interpolation or escape sequences are needed. Learn more: https://www.php.net/manual/en/language.types.string.php

You have a PHP script and you need to store information about a user session. How would you do this using a superglobal?

  • Use the $_SESSION superglobal.
  • Use the $_COOKIE superglobal.
  • Use the $_SERVER superglobal.
  • Use the $_GLOBALS superglobal.
The correct option is 1. To store information about a user session in PHP, you would use the $_SESSION superglobal. The $_SESSION superglobal is an associative array that allows you to store and access session variables. It is used to maintain session data across multiple page requests for a specific user. By storing data in $_SESSION, you can preserve user-specific information throughout their interaction with your web application. The session data is stored on the server and can be accessed across different pages or scripts as long as the session is active. Learn more: https://www.php.net/manual/en/reserved.variables.session.php

The == operator in PHP is a type of ______ operator.

  • Comparison
  • Arithmetic
  • Assignment
  • Logical
The == operator in PHP is a type of comparison operator. It is used to compare two values for equality. The == operator checks if the values on both sides are equal, regardless of their data types. For example, $num1 == $num2 will return true if $num1 is equal to $num2, and false otherwise. Learn more: https://www.php.net/manual/en/language.operators.comparison.php

Which of the following are true about the if statement in PHP?

  • It executes a block of code if a condition is true
  • It can test multiple conditions
  • It can be nested within another if statement
  • It can only be used with numerical values
The if statement in PHP executes a block of code if a condition is true. It allows you to test a condition and execute code based on the result. The if statement can handle both simple conditions and complex conditions involving logical operators. It can be used to test multiple conditions by using logical operators or by nesting if statements within each other. It is a fundamental control structure in PHP and is widely used for decision-making and flow control. Learn more: https://www.php.net/manual/en/control-structures.if.php

In PHP, Regular Expressions are sequences of characters that form a search pattern, used mainly for ______.

  • Text manipulation
  • Generating random numbers
  • Sorting arrays
  • Mathematical calculations
In PHP, Regular Expressions are sequences of characters that form a search pattern, used mainly for text manipulation. Regular expressions provide a powerful and flexible way to search, match, and manipulate strings based on specific patterns. They can be used for tasks such as validating inputs, extracting data, performing string substitutions, and more. Regular expressions enable developers to define complex search patterns and apply them to strings, making it easier to work with textual data. Learn more: https://www.php.net/manual/en/book.regex.php

What are some common use cases for FTP functions in PHP?

  • Uploading files to an FTP server, downloading files from an FTP server
  • String manipulation, database querying
  • Image processing, networking operations
  • All of the above
FTP functions in PHP have various use cases. Some common ones include uploading files to an FTP server, downloading files from an FTP server, synchronizing local and remote directories, retrieving directory listings, creating or deleting directories on an FTP server, and performing other file transfer operations. FTP functions enable PHP scripts to automate file transfers, backup data to remote servers, retrieve files from external sources, or build applications that interact with FTP servers. They provide flexibility and control over file transfer operations in PHP programming.

You need to check if a variable in your PHP script is an integer. How would you do this?

  • is_int($variable)
  • is_string($variable)
  • is_float($variable)
  • is_numeric($variable)
To check if a variable is an integer in PHP, you can use the is_int() function. The is_int() function checks if a variable is of type integer. It returns true if the variable is an integer and false otherwise. This function is useful when you specifically need to verify that a variable is of integer type. Learn more: https://www.php.net/manual/en/function.is-int.php

You have a PHP script and you need to move an uploaded file to a specific directory. How would you do this?

  • move_uploaded_file()
  • copy()
  • move_file()
  • attach_file()
To move an uploaded file to a specific directory in PHP, you can utilize the move_uploaded_file() function. This function moves the file to the desired directory. Check out: http://php.net/manual/en/function.move-uploaded-file.php