PHP MCQs for Beginners

PHP MCQs for Beginners 1: Which of the following is NOT a valid PHP data type? a) String b) Integer c) Array d) Boolean Show Ans...

PHP MCQs for Beginners

1: Which of the following is NOT a valid PHP data type?

  • a) String
  • b) Integer
  • c) Array
  • d) Boolean

c) Array

2: What does PHP stand for?

  • a) Personal Hypertext Processor
  • b) Preprocessed Hypertext Pages
  • c) PHP: Hypertext Preprocessor
  • d) PHP Hypertext Page

c) PHP: Hypertext Preprocessor

3: Which of the following is the correct way to start a PHP script?

  • a) <?php start ?>
  • b) <?php
  • c) <?start?>
  • d) <?php>

b)

4: Which PHP function is used to open a file for reading?

  • a) read_file()
  • b) open_file()
  • c) fopen()
  • d) file_open()

c) fopen()

5: What is the correct operator for concatenating two strings in PHP?

  • a) .
  • b) +
  • c) –
  • d) *

a) .

6: What is the output of the following PHP code: echo strlen(“Hello World”); ?

  • a) 10
  • b) 11
  • c) 12
  • d) 13

b) 11

7: Which of the following is used to comment a single line in PHP?

  • a) //
  • b) /*
  • c) #
  • d) ;

a) //

8: Which of the following PHP functions is used to delete a file?

  • a) delete_file()
  • b) remove_file()
  • c) unlink()
  • d) file_delete()

c) unlink()

9: Which superglobal variable in PHP is used to retrieve information about HTTP cookies?

  • a) $_SESSION
  • b) $_COOKIE
  • c) $_GET
  • d) $_POST

b) $_COOKIE

10: What is the output of the following PHP code: echo 10 % 3; ?

  • a) 1
  • b) 3
  • c) 7
  • d) 0

a) 1

PHP MCQ Online Test

11: Which of the following is NOT a comparison operator in PHP?

  • a) ===
  • b) ==
  • c) <>
  • d) <=>

d) <=>

12: Which PHP function is used to redirect the user to a different URL?

  • a) redirect()
  • b) header()
  • c) location()
  • d) forward()

b) header()

13: What is the correct way to end a PHP statement?

  • a) ;
  • b) :
  • c) .
  • d) {

a) ;

14: Which PHP function is used to check if a file or directory exists?

  • a) is_file()
  • b) file_exists()
  • c) exists()
  • d) check_file()

b) file_exists()

15: What is the output of the following PHP code: echo strtoupper(“php is fun”); ?

  • a) php is fun
  • b) PHP is FUN
  • c) PHP IS FUN
  • d) php IS fun

c) PHP IS FUN

16: Which of the following is used to start a session in PHP?

  • a) session_start()
  • b) start_session()
  • c) session()
  • d) initiate_session()

a) session_start()

17: Which PHP function is used to retrieve the current date and time?

  • a) date()
  • b) time()
  • c) now()
  • d) current_datetime()

a) date()

18: What is the output of the following PHP code: echo 2 + “3”; ?

  • a) 5
  • b) 23
  • c) 32
  • d) Error

a) 5

19: Which of the following is used to define a constant in PHP?

  • a) define()
  • b) const()
  • c) constant()
  • d) set_constant()

a) define()

20: What does the PHP function “mysqli_connect()” do?

  • a) Connects to a MySQL database
  • b) Connects to a Microsoft SQL Server database
  • c) Connects to a MongoDB database
  • d) Connects to a PostgreSQL database

Answer: a)

PHP Exam Questions and Answers

21: What is the correct way to declare a PHP array?

  • a) array(1, 2, 3)
  • b) [1, 2, 3]
  • c) (1, 2, 3)
  • d) {1, 2, 3}

b) [1, 2, 3]

22: Which of the following functions is used to remove whitespace from the beginning and end of a string in PHP?

  • a) trim()
  • b) strip()
  • c) remove_whitespace()
  • d) clean()

a) trim()

23: What is the output of the following PHP code: echo strlen(“PHP”); ?

  • a) 1
  • b) 2
  • c) 3
  • d) 4

c) 3

24: Which PHP function is used to convert a string to lowercase?

  • a) strtolower()
  • b) lcstring()
  • c) lower()
  • d) tolower()

a) strtolower()

25: What is the purpose of the PHP function “session_destroy()”?

  • a) Starts a new session
  • b) Destroys all session variables
  • c) Deletes a specific session variable
  • d) Resets the session ID

Answer: b)

26: Which PHP function is used to count the number of elements in an array?

  • a) array_count()
  • b) array_length()
  • c) count()
  • d) length()

c) count()

27: What is the output of the following PHP code: echo pow(2, 3); ?

  • a) 6
  • b) 8
  • c) 16
  • d) 23

b) 8

28: Which of the following is the correct way to declare a PHP class?

  • a) class MyClass { }
  • b) MyClass = new class { }
  • c) define MyClass { }
  • d) new MyClass { }

a) class MyClass { }

29: Which PHP function is used to delete a specific cookie?

  • a) delete_cookie()
  • b) remove_cookie()
  • c) unset_cookie()
  • d) setcookie()

c) unset_cookie()

30: What is the output of the following PHP code: echo “10” + 5; ?

  • a) 15
  • b) 105
  • c) “105”
  • d) Error

a) 15

Advance PHP MCQs

31: Which of the following is used to check if a variable is an array in PHP?

  • a) isarray()
  • b) is_array()
  • c) isArray()
  • d) check_array()

b) is_array()

32: What is the purpose of the PHP function “mysqli_query()”?

  • a) Executes a MySQL query
  • b) Executes a MongoDB query
  • c) Executes a PostgreSQL query
  • d) Executes a SQLite query

a) Executes a MySQL query

33: What is the correct way to include an external PHP file?

  • a) include(“file.php”);
  • b) import(“file.php”);
  • c) require(“file.php”);
  • d) load(“file.php”);

c) require(“file.php”);

34: What is the output of the following PHP code: echo “Hello” . “World”; ?

  • a) HelloWorld
  • b) Hello World
  • c) HelloWorld
  • d) Error

b) Hello World

35: Which PHP function is used to format a number with a specific number of decimal places?

  • a) format_number()
  • b) number_format()
  • c) decimal_format()
  • d) format_decimal()

b) number_format()

36: What is the purpose of the PHP function “array_push()”?

  • a) Removes an element from an array
  • b) Adds an element to the end of an array
  • c) Reverses the order of elements in an array
  • d) Checks if an element exists in an array

Answer: b)

37: What is the output of the following PHP code: echo strpos(“Hello World”, “o”); ?

  • a) 4
  • b) 7
  • c) 9
  • d) 11

a) 4

38: Which PHP function is used to redirect the user to the previous page?

  • a) redirect_previous()
  • b) header(“Referer: “)
  • c) previous_page()
  • d) go_back()

b) header(“Referer: “)

39: What is the purpose of the PHP function “mysqli_fetch_assoc()”?

  • a) Fetches a row from a MySQL result set as an associative array
  • b) Fetches a row from a MongoDB result set as an associative array
  • c) Fetches a row from a PostgreSQL result set as an associative array
  • d) Fetches a row from a SQLite result set as an associative array

Answer: a)

40: What is the output of the following PHP code: echo round(3.75); ?

  • a) 3
  • b) 4
  • c) 3.5
  • d) 4.5

b) 4

COMMENTS

TECH$type=three$author=hide

Name

5g & 6g Technology Solved MCQs,1,Abbreviations,1,Accounting & Auditing,1,Active Voice,1,Agriculture,1,Agriculture Solved,1,Air Pollution,1,Allama Iqbal,1,Amazon Web Services AWS solved MCQs,1,Antibiotics,1,Antonyms,1,Artificial Intelligence,2,ASF,1,Assistant,6,Auditing,1,Authors,1,Banking,1,Battles,1,Battles of Islam,1,Bioinformatics,1,Biological Science,1,Biology,49,Blockchain Technology,1,Books,1,Botany,1,British History,1,Business,1,Business Administration,1,Carbohydrates,2,Carbon,1,Carbon Neutrality,1,Cell,1,Cell organelles,1,ChatGPT,1,CHEMISTRY,3,Chromosomes,2,City Names,1,Clerk,1,Code Of Criminal Procedure 1898,1,Communication Skills,1,Components of Food,1,Compounds,1,Computer,4,Computer Science,5,Constitutional Law,1,Coordination,1,Corona Virus,1,Correct Spelling,1,Cryptocurrency,1,CSS,6,CSS MPT,2,Current Affairs,6,Current affairs of Pakistan,1,Current affairs Pakistan,1,Cybersecurity,1,Database,1,DeepSeek,1,Digestion and Absorption,1,Digital Detox,1,Diseases,1,Economics,2,Ecosystem,1,Edge Computing,1,Education,2,Educational Psychology,1,Engineering,3,English,16,English Grammar,6,English Literature,1,english Litrature,1,English Precis and Composition,1,English Prepositions,1,English Synonyms,1,Entomology,1,Entrepreneurship,1,Erythropoietin,1,European History,1,Everyday,1,Everyday Science,6,Everyday Science Solved,1,Fabric,1,Factors,1,FBR,2,FBR Jobs Test,1,Fibre,1,Finance,1,Fisheries,1,Food Microbiology,1,Fossils,1,FPSC,3,FPSC Assistant Solved MCQs,1,Gender Studies,1,General Knowledge,20,General Knowledge Pakistan,1,General Science,1,Generative AI,1,Geography,1,Geology,1,GMAT Test,1,Grammar,1,GRE Test,1,Green Energy,1,Green Technology,1,Hazrat Muhammad PBUH,1,Health and Hygiene,1,Health Physical Education,1,Histology,1,History,1,IBA University,1,IELT Test,1,Immunity,1,Immunology,1,Indo-pak,1,Infectious Diseases,1,Inheritance,1,Inter provincial coordination,1,International Law,2,International Relations,2,Inventions,1,Islam,8,Islamiat,8,Islamic Banking,1,Islamic History,1,IT,4,JavaScript,1,Journalism Mass Communication,1,LDC,1,Library Information,1,Liver,1,Lower Division Clerk,1,Lysosome,1,Machine Learning,1,Management,1,Market Management,1,Mass Communication,1,Mathematics,2,Medical,5,Memory,1,Mercantile Law,1,Metabolism,1,Microbiology,1,Microbiology Solved MCQs,1,Mineral,1,Minerals,1,Ministry of Defense (MOD),3,MPT,1,Multiples,1,Municipal Officer,1,Muslim Law Jurisprudence,1,NASA,1,National,3,National Heritage and Culture,1,Neural Control,1,Neurology,1,NTS,3,Nutrition,2,Nutrition in Plants,1,Operating System,1,Others,5,Pak Studies,1,Pakistan,11,Pakistan Affairs,1,Pakistan Penal Code 1860,1,Pakistan Studies,4,PCR,1,Pedagogy,1,Pharmaceutics,1,Pharmacy,1,PHP,1,Phylum Mollusca,1,Physical Education,1,Physics,1,Plant Growth and Development,1,plant protection department,1,Plant Tissue Culture,1,Ploitical Science,1,Pollution,2,Polymerase Chain Reaction,1,Postal Clerk,2,Postman,1,PPSC,8,Principles of Inheritance and Variation,1,Proteins,1,Psychology,1,Public Administration,1,Punjab Land Revenue Act,1,Reproduction in Organisms,1,Respiration,1,Respiratory system,1,Saraiki Culture,1,SCIENCE,2,Screening test,1,Signaling,1,Sociology,1,Solid Waste Management,1,Sports,2,Structural Organization in Animals,1,Surface Area & Volume,1,TEACHING,5,Town Officer,1,Transport in Plants,1,UDC,1,Universe,2,UOS (University of Sargodha),1,Upper Division Clerk,1,URDU,9,USA History,1,Viruses,1,Vitamins,2,Water Pollution,1,Web3,1,Web3 Technology,1,World,20,World Famous,1,World-GK,1,Zoology,3,Zoology Botany,1,
ltr
item
SOLVED MCQs FOR ALL: PHP MCQs for Beginners
PHP MCQs for Beginners
https://blogger.googleusercontent.com/img/a/AVvXsEipkCXGFpt4f9sscXVq3xQIPCrI3ubxXuiSsEZUGCxsq-hBfqWAx9bnzNQ6uBblb_7rh3lMG-qJnOjcWUEto2I4YepkTUwDCMGKi9SWTLOxX6SluIHGseRTT4_ZqC878cejJ6sj2t-rgwVf0-Ju582qiUtB5ShI7Xr9PrDgYrSiq2Cn3kZdecZSKZUyrVA
https://blogger.googleusercontent.com/img/a/AVvXsEipkCXGFpt4f9sscXVq3xQIPCrI3ubxXuiSsEZUGCxsq-hBfqWAx9bnzNQ6uBblb_7rh3lMG-qJnOjcWUEto2I4YepkTUwDCMGKi9SWTLOxX6SluIHGseRTT4_ZqC878cejJ6sj2t-rgwVf0-Ju582qiUtB5ShI7Xr9PrDgYrSiq2Cn3kZdecZSKZUyrVA=s72-c
SOLVED MCQs FOR ALL
https://solvedmcqs.blogspot.com/2023/07/php-mcqs-for-beginners.html
https://solvedmcqs.blogspot.com/
https://solvedmcqs.blogspot.com/
https://solvedmcqs.blogspot.com/2023/07/php-mcqs-for-beginners.html
true
3555367411482497961
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content