PHP Programming

PHP OOPs MCQ

1. What keyword is used to declare a class in PHP? a) class b) Class c) declare d) new Click to View Answer and Explanation Answer: a) class Explanation: The 'class' keyword is used to declare a class in PHP. 2. How do you create an instance of a class in PHP? a) new ClassName()

PHP OOPs MCQ Read More »

PHP File Handling MCQ

1. How do you open a file in PHP? a) open('filename', 'mode') b) fopen('filename', 'mode') c) file_open('filename', 'mode') d) open_file('filename', 'mode') Click to View Answer and Explanation Answer: b) fopen('filename', 'mode') Explanation: The fopen() function is used to open a file in a specified mode in PHP. 2. Which mode in fopen() function is used

PHP File Handling MCQ Read More »

PHP Functions MCQ

1. How do you declare a function in PHP? a) function myFunction() { … } b) declare myFunction() { … } c) create myFunction() { … } d) newFunction myFunction() { … } Click to View Answer and Explanation Answer: a) function myFunction() { … } Explanation: Functions in PHP are declared using the 'function'

PHP Functions MCQ Read More »

PHP Loops MCQ

1. Which of these is a loop structure in PHP? a) if b) while c) echo d) isset Click to View Answer and Explanation Answer: b) while Explanation: The while loop is a loop structure in PHP that executes a block of code as long as the specified condition is true. 2. What is the

PHP Loops MCQ Read More »

PHP Operators MCQ

1. What does the '==' operator do in PHP? a) Assigns a value b) Compares two values for equality c) Adds two values d) Checks if one value is greater than the other Click to View Answer and Explanation Answer: b) Compares two values for equality Explanation: The '==' operator is used for comparing two

PHP Operators MCQ Read More »

PHP Constants MCQ

1. Which function is used to define a constant in PHP? a) set_constant() b) const() c) define() d) constant() Click to View Answer and Explanation Answer: c) define() Explanation: The define() function is used to define a constant in PHP. 2. Once a constant is defined in PHP, can its value be changed? a) Yes

PHP Constants MCQ Read More »

PHP Math MCQ

1. Which function is used to calculate the absolute value of a number in PHP? a) abs() b) fabs() c) absolute() d) mod() Click to View Answer and Explanation Answer: a) abs() Explanation: The abs() function is used to calculate the absolute value of a number in PHP. 2. How do you generate a random

PHP Math MCQ Read More »

PHP Numbers MCQ

1. What is the largest integer value supported in 64-bit PHP? a) 2^31 – 1 b) 2^63 – 1 c) 9,223,372,036,854,775,807 d) 4,294,967,295 Click to View Answer and Explanation Answer: b) 2^63 – 1 Explanation: In a 64-bit version of PHP, the largest integer is 2^63 – 1. 2. How is a hexadecimal number specified

PHP Numbers MCQ Read More »

PHP Strings MCQ

1. Which function is used to find the length of a string in PHP? a) strlen() b) strlength() c) length() d) len() Click to View Answer and Explanation Answer: a) strlen() Explanation: The strlen() function is used to find the length of a string in PHP. 2. How do you concatenate two strings in PHP?

PHP Strings MCQ Read More »

PHP Data Types MCQ

1. Which of the following is a scalar data type in PHP? a) Array b) Object c) Boolean d) NULL Click to View Answer and Explanation Answer: c) Boolean Explanation: Boolean is a scalar data type in PHP, representing two possible values: true or false. 2. What data type is used for textual data in

PHP Data Types MCQ Read More »

PHP MCQ

Welcome to Quiz on PHP. PHP is one of the most versatile server-side scripting languages, PHP powers a significant portion of the web. From websites to online applications, its ubiquity is undeniable. Whether you are a newbie aiming to grasp the foundational concepts or a seasoned developer looking to brush up on your PHP knowledge,

PHP MCQ Read More »

Scroll to Top