Online Exam Quiz

questionQuestion  1 to 30

Which of the following is the right way to get the length of a string in PHP?

  • strlen($string)
  • length($string)
  • size($string)
  • strlength($string)
Mark for review

How do you delete a file in PHP?

  • unlink("file.txt");
  • delete("file.txt");
  • remove("file.txt");
  • erase("file.txt");
Mark for review

How do you connect to a MySQL database in PHP?

  • $conn = new mysqli($host, $user, $pass)
  • $conn = connect($host, $user, $pass)
  • $conn = mysql($host, $user, $pass)
  • $conn = db_connect($host, $user, $pass)
Mark for review

How do you declare an abstract class in PHP?

  • abstract class MyClass { }
  • class abstract MyClass { }
  • class MyClass abstract { }
  • abstract MyClass { }
Mark for review

How do you format a number with grouped thousands in PHP?

  • number_format($number)
  • format_number($number)
  • num_format($number)
  • number_group($number)
Mark for review

How do you append to a file in PHP?

  • fopen("file.txt", "a");
  • open("file.txt", "a");
  • append("file.txt", "a");
  • file_append("file.txt", "a");
Mark for review

How do you define a constructor in a PHP class?

  • function __construct() { }
  • function construct() { }
  • function __construct() { }
  • function: construct() { }
Mark for review

What is the output of echo (int)( (0.1+0.7) * 10 );?

  • 7
  • 8
  • 9
  • 10
Mark for review

How can you get the number of elements in an array in PHP?

  • count($array)
  • size($array)
  • length($array)
  • elements($array)
Mark for review

Which of the following is used to generate a random number in PHP?

  • rand()
  • random()
  • generate_rand()
  • rand_number()
Mark for review

Which of the following is used to check if a variable is of integer type in PHP?

  • is_int()
  • is_integer()
  • check_int()
  • Both is_int() and is_integer()
Mark for review

Which of the following is used to terminate the execution of a script in PHP?

  • exit()
  • die()
  • stop()
  • Both exit() and die()
Mark for review

What will strpos("Hello world", "world"); return?

  • 5
  • 6
  • 7
  • 8
Mark for review

Which of the following is used to check if a file exists in PHP?

  • file_exists()
  • is_file()
  • exists_file()
  • check_file()
Mark for review

Which of the following is a way to comment in PHP?

  • // This is a comment
  • /* This is a comment */
  • # This is a comment
  • All of the above
Mark for review

Which function is used to output text in PHP?

  • echo
  • print
  • write
  • show
Mark for review

Which of the following is a superglobal in PHP?

  • $_POST
  • $GLOBALS
  • $_SESSION
  • All of the above
Mark for review

Which of the following is the correct way to end a PHP statement?

  • ;
  • .
  • :
  • #
Mark for review

What will substr("abcdef", 1, 3); return?

  • bcd
  • abc
  • cde
  • def
Mark for review

What does PDO stand for?

  • PHP Data Object
  • PHP Database Object
  • PHP Data Orientation
  • PHP Database Orientation
Mark for review

What will strtolower("HELLO"); return?

  • hello
  • HELLO
  • Hello
  • hElLo
Mark for review

How do you define a constant in PHP?

  • define("CONSTANT", "value");
  • constant("CONSTANT", "value");
  • const CONSTANT = "value";
  • define: CONSTANT = "value";
Mark for review

Which of the following is the correct way to create a class in PHP?

  • class MyClass { }
  • create class MyClass { }
  • define class MyClass { }
  • class: MyClass { }
Mark for review

How do you check if a variable is an array in PHP?

  • is_array($var)
  • check_array($var)
  • isArray($var)
  • array_check($var)
Mark for review

PHP files have a default file extension of...

  • .html
  • .xml
  • .php
  • .js
Mark for review

What is the correct way to include a file only once in PHP?

  • include_once "file.php";
  • include "file.php";
  • require_once "file.php";
  • require "file.php";
Mark for review

Which of the following is a PHP variable?

  • $var
  • var
  • @var
  • #var
Mark for review

How do you find the position of the first occurrence of a substring in a string in PHP?

  • strpos()
  • find()
  • search()
  • locate()
Mark for review

How do you check if a variable is empty in PHP?

  • empty($var)
  • is_empty($var)
  • check_empty($var)
  • empty_check($var)
Mark for review

How do you remove all leading and trailing whitespace in PHP?

  • trim($string)
  • strip($string)
  • clean($string)
  • whitespace_remove($string)
Mark for review

blinkerOnline

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • Answered
  • Not Answered
  • Marked for Review