What is the output of the following PHP code? class Patient { public $name; public $age; public function __construct($name, $age) { $this->name = $name; $this->age = $age; } public function getDetails() { return $this->name . " is " . $this->age . " years old."; } } $p1 = new Patient("Alice", 32); echo $p1->getDetails();

PHP Code Output Quiz

Quiz
•
Computers
•
University
•
Easy
Karen Tan
Used 2+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 15 pts
Alice is 32 years old.
Alice -> 32
Name: Alice, Age: 32
Error: Undefined method
2.
MULTIPLE CHOICE QUESTION
2 mins • 15 pts
What will the following PHP code display? function calcBMI($weight, $height) { $bmi = $weight / ($height * $height); return round($bmi, 2); } echo calcBMI(65, 1.75);
22.45
21.22
23.33
20.67
3.
MULTIPLE CHOICE QUESTION
2 mins • 15 pts
What is the output of the following code snippet? $products = ["Shoes" => 50, "Shirts" => 30, "Jeans" => 40]; function applyDiscount(&$items, $discount) { foreach ($items as $item => &$price) { $price -= ($price * $discount / 100); } } applyDiscount($products, 10); echo $products["Shoes"];
40
50
45
55
4.
MULTIPLE CHOICE QUESTION
2 mins • 15 pts
What will the code display? $inventory = [ "Product" => "Laptop", "Stock" => 15, "Price" => 75000 ]; echo json_encode($inventory);
Array (Product => Laptop, Stock => 15, Price => 75000)
Product => Laptop, Stock => 15, Price => 75000
Laptop, 15, 75000
{"Product":"Laptop","Stock":15,"Price":75000}
5.
MULTIPLE CHOICE QUESTION
2 mins • 15 pts
What will the following PHP snippet display? $students = ["John" => 85, "Alice" => 90, "Bob" => 78]; function getTopStudent($arr) { arsort($arr); return key($arr); } echo getTopStudent($students);
Alice
John
Bob
Undefined
6.
MULTIPLE CHOICE QUESTION
2 mins • 15 pts
What will be the output? class Student { public $name; public $grade; public function __construct($name, $grade) { $this->name = $name; $this->grade = $grade; } public function isPassed() { return $this->grade >= 75 ? "Passed" : "Failed"; } } $s = new Student("Emma", 72); echo $s->isPassed();
Undefined
Passed
Failed
Error
7.
MULTIPLE CHOICE QUESTION
2 mins • 15 pts
What will the following PHP code display? function calcCost($hours, $rate) { return $hours * $rate; } echo calcCost(40, 35);
1400
1350
1450
1300
Create a free account and access millions of resources
Similar Resources on Quizizz
14 questions
5.3.0 Database Schema Quizizz

Quiz
•
University
10 questions
PHP

Quiz
•
University
10 questions
PHP Introduction - Assignment 1

Quiz
•
University
10 questions
PHP MySQL

Quiz
•
University
10 questions
PHP Basics

Quiz
•
University
15 questions
PHP with MySQL quiz

Quiz
•
University
9 questions
PWD_TP1_TP2_TP3

Quiz
•
University
10 questions
Struktur Percabangan PHP

Quiz
•
2nd Grade - University
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade