adplus-dvertising

Welcome to the Objects and Databases in PHP MCQs Page

Dive deep into the fascinating world of Objects and Databases in PHP with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Objects and Databases in PHP, a crucial aspect of PHP. In this section, you will encounter a diverse range of MCQs that cover various aspects of Objects and Databases in PHP, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within PHP.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Objects and Databases in PHP. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of PHP.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Objects and Databases in PHP. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Objects and Databases in PHP MCQs | Page 1 of 10

Q1.
What will be the output of the following PHP code?
<?php
    $number = array(0,1,two,three,four,5);
    $num = preg_grep("/[0-5]/", $number);
    print_r($num);
    ?>
Discuss
Answer: (d).Array([0]=>0 [1]=>1 [5]=>5)
Q2.
What will be the output if we replace the line $num = preg_grep(“/[0-5]/”, $number); with $num = preg_grep(“/[0-5]/”, $number, PREG_GREP_INVERT);?
Discuss
Answer: (b).Array([2]=>two [3]=>three [4]=>four)
Q3.
Which one of the following functions is used to search a string?
Discuss
Answer: (a).preg_match
Q4.
What will be the output of the following PHP code?
<?php
    $name = "What is your name?"
    if (preg_match("/name/"),$name)
    echo "My name is Will Pitt ";
    else
    echo "My name is not Will Pitt ";
    if (preg_match("/are/"))
    echo "I am great"
    else
    echo "I am not great";    
    ?>
Discuss
Answer: (c).My name is Will Pitt I am not great
Q5.
Which one of the following preg PHP function is used to do a find and replace on a string or an array?
Discuss
Answer: (a).preg_replace()
Q6.
What will be the output of the following PHP code?
<?php
    $str = "Hello! My name is Cameron Fox. Coffee?"
    $find = array('/is/','/coffee/');
    $replace = array('/was/','/tea/');
    echo preg_replace ($find, $replace, $str);
    ?>
Discuss
Answer: (d).Hello! My name was Cameron Fox. Coffee?
Q7.
Which one of the following preg PHP functions is used to take a string, and put it in an array?
Discuss
Answer: (b).preg_split()
Q8.
What will be the output of the following PHP code?
<?php
    $line = "You like dogs. I hate dogs. We should marry."
    $sen = preg_split('/\./', $line);
    print_r($sen);
    ?>
Discuss
Answer: (c).Array([0]=>You like dogs. [1]=>I hate dogs. [2]=>We should marry.)
Q9.
Which one of the following is not a preg PHP function?
Discuss
Answer: (c).preg_matchall
Q10.
Parameter flags was added in which version of PHP?
Discuss
Answer: (d).PHP 4.3
Page 1 of 10

Suggested Topics

Are you eager to expand your knowledge beyond PHP? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!