thumbnail

PHP Quiz for dummies #1

Easy PHP questions #1
Quiz by textreader
Rate:
Last updated: March 14, 2024
You have not attempted this quiz yet.
First submittedMarch 13, 2024
Times taken11
Average score57.1%
Report this quizReport
5:00
The quiz is paused. You have remaining.
Scoring
You scored / = %
This beats or equals % of test takers also scored 100%
The average score is
Your high score is
Your fastest time is
Keep scrolling down for answers and more stats ...
1. What does PHP stand for?
Proper Hypertext Processor
PHP: Hypertext Preprocessor
Hypertext Preprocessor
None of the above
2. How do you declare a variable in PHP?
variable = 1;
$variable 1;
$variable = 1;
$variable = 1
3. How do you declare a array in PHP?
array = [];
$array = array();
$array = arr();
$array[] = [];
4. How do you declare a function in PHP?
function myFunction(parameters) {body}
new function myFunction(parameters) {body}
myFunction(parameters) {body}
string myFunction(parameters) {body}
5. Which loops does PHP support?
foreach
for
while
All of the above
6. How do you import a file in PHP?
include 'file.php, read';
include 'file.php';
import 'file.php';
import 'file.php, read';
7. How do you define a class in PHP?
class Fruits {}
new class Fruits {}
Fruits {}
Fruits = class {}
8. Select the correct code. (Can be more than 1)
function myMessage() { echo "Hello world!"; }
$greet = function($name) { echo"Hello world!"; };
class Fruit {public $name; public $color; function set_name($name) { $this->name = $name; } function get_name() { return $this->name; } }
All of the above
9. Which of the below is correct?
Try/catch does not catch errors.
Try/catch works for warnings.
PHP can interact with DOM.
None of the above.
10. Which one of these is a datatype in PHP?
String
Resource
NULL
All of the above
11. How do you access the headers, paths, and script locations.
$_GET
$SERVER
$_SERVER
$_POST
12. How do you read a file in PHP?
readfile(filename);
read(readfile(filename););
file_get_contents(filename);
import(filename);
13. How do you call a private static variable inside a function of a class?
$this->$variable
self::$variable
$variable
None of the above
14. How do you declare a constructor in PHP?
function _constructor(){}
function __constructor() {}
function __construct() {}
__construct () {}
Comments
No comments yet