Server-side Web Development (I3302) 2017-2018 PHP Language Quiz
19 Questions
2 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

In PHP, which function is used to display text?

  • display_text()
  • print_r()
  • printf()
  • echo() (correct)
  • What is the purpose of the 'date()' function in PHP?

  • To display the date of the last server restart
  • To retrieve the current server date
  • To format and display the current server date and time (correct)
  • To create a new date variable
  • Which method is used to pass variables in PHP through the URL?

  • PUT method
  • DATA method
  • GET method (correct)
  • POST method
  • What does the 'include' statement do in PHP?

    <p>It includes another PHP file in the current PHP script</p> Signup and view all the answers

    In PHP, what does the 'define()' function do?

    <p>It declares a constant</p> Signup and view all the answers

    Which type of array in PHP uses named keys that you assign to them?

    <p>Associative array</p> Signup and view all the answers

    What is the purpose of the 'exit()' function in PHP?

    <p>To terminate the script and return a value to the calling code</p> Signup and view all the answers

    How can environment variables be accessed in PHP?

    <p>$_SERVER['variable_name']</p> Signup and view all the answers

    Which of these is used to stop the execution of a script in PHP?

    <p>'exit'</p> Signup and view all the answers

    What tags are used to display bold text in PHP?

    Signup and view all the answers

    In PHP, how can you convert a variable into a primitive type by casting?

    <p>(int)$var</p> Signup and view all the answers

    Which function in PHP returns true if the variable is empty?

    <p>empty($var)</p> Signup and view all the answers

    What is the syntax for assigning a variable identifier the value of another variable in PHP?

    <p>${$var} = value;</p> Signup and view all the answers

    In PHP, what is the purpose of the isset($var) function?

    <p>Returns true if the variable exists</p> Signup and view all the answers

    What does the following syntax do in PHP: $name_variable = 3;

    <p>Assigns the value 3 to the variable $name_variable</p> Signup and view all the answers

    In PHP, what is the purpose of the unset($var) function?

    <p>Destroys a variable</p> Signup and view all the answers

    In PHP, what does $nbr = (int)$str; do?

    <p>$nbr equals to $str as an integer</p> Signup and view all the answers

    What are the three sorts of 'data' that can be stored in a variable in PHP?

    <p>text, numbers, or boolean</p> Signup and view all the answers

    $str = '12'; $nbr = (int)$str; // What does $nbr equal to after this in PHP?

    Signup and view all the answers

    Study Notes

    PHP Functions and Syntax

    • The echo function is used to display text in PHP.

    Date and Time

    • The date() function returns the current date and time.

    Passing Variables

    • Variables can be passed through the URL using the GET method.

    Including Files

    • The include statement is used to insert the contents of one PHP file into another.

    Defining Constants

    • The define() function is used to define a constant.

    Array Types

    • An associative array is a type of array that uses named keys that are assigned to them.

    Script Execution

    • The exit() function is used to stop the execution of a script.

    Environment Variables

    • Environment variables can be accessed in PHP using the $_SERVER or $_ENV superglobals.

    Stopping Script Execution

    • The die() or exit() function is used to stop the execution of a script.

    Displaying Bold Text

    • The <b> tag is used to display bold text in PHP.

    Casting Variables

    • A variable can be converted to a primitive type by casting using the (type) syntax.

    Checking Variable Emptiness

    • The empty() function returns true if the variable is empty.

    Variable Assignment

    • The syntax for assigning a variable identifier the value of another variable is $var2 = $var1.

    Variable Existence

    • The isset() function checks if a variable is set and is not null.

    Variable Unsetting

    • The unset() function is used to unset a variable.
    • The unset() function sets a variable to null.

    Type Casting

    • $nbr = (int)$str; casts the string $str to an integer and assigns it to $nbr.

    Data Types

    • Three types of data that can be stored in a variable in PHP are strings, integers, and floats.
    • After $str = '12'; $nbr = (int)$str;, $nbr equals 12.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Test your knowledge of PHP language and server-side web development concepts such as displaying text, using comments, functions like date(), passing variables with get and post, including external files, working with variables and constants, control instructions, dynamic functions, environment variables, arrays, and associative arrays.

    More Like This

    Use Quizgecko on...
    Browser
    Browser