Explore topic-wise MCQs in Php.

This section includes 27 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

1.

*$_What will be the output of the following code? If say date is 22/06/2013.?

A. Today is 22 June, 2013
B. Today is 22-06-2013
C. Today is 06-22-2013
D. Today is June 22, 2013
Answer» E.
2.

*/*_What will be the output of the following PHP code if date is 24/02/2008?format('l,F,js,Y')?>?

A. Sunday, February 24th 2008
B. Sunday, 02 24 2008
C. Sunday, 24 02 2008
D. Sunday, 24th February 2008
Answer» B. Sunday, 02 24 2008
3.

*/*_To create an object and set the date to JUNE 22, 2013, which one of the following statement should be executed??

A. $date = Date(“22 JUNE 2013”)
B. $date = new Date(“JUNE 22 2013”)
C. $date = DateTime(“22 JUNE 2013”)
D. $date = new DateTime(“22 JUNE 2013”)
Answer» E.
4.

*/*_Which method enables you to calculate whether daylight saving time is in force at a specific date and time??

A. getOffset()
B. getTranitions()
C. ISODate()
D. savingTime()
Answer» C. ISODate()
5.

_ If the format is F then which one of the following will be returned?$?

A. Complete text representation of month
B. Day of month, with leading zero
C. Daylight saving time
D. Day of month, without zeros
Answer» B. Day of month, with leading zero
6.

__Which of the following is the right way to use the DateTime class?__

A. $date = get_Class(DateTime);
B. $date = class DateTime;
C. $date = new DateTime();
D. $date = new class DateTime();
Answer» D. $date = new class DateTime();
7.

__Say you want to calculate the date 45 days from the present date which one of the following statement will you use?__

A. totime(“+45”)
B. totime(“+45 days”)
C. strtotime(“+45 days”)
D. strtotime(“-45 days”)
Answer» D. strtotime(‚Äö√Ñ√∫-45 days‚Äö√Ñ√π)
8.

__Which of the following statements can be used to add two months to the existing date?__

A. $date->modify(‘+2 months’);
B. $date = modify(‘+2 months’);
C. $date = modify(‘2+ months’);
D. $date->modify(‘2+ months’);
Answer» B. $date = modify(‚Äö√Ñ√≤+2 months‚Äö√Ñ√¥);
9.

_Which one of the following format parameter can be used to identify timezone?$?

A. T
B. N
C. E
D. I
Answer» D. I
10.

Which method is simply an object-oriented version of date()?$?

A. DateTime::format()
B. DateTime::modify()
C. DateTime::setTime()
D. DateTime::setDate()
Answer» B. DateTime::modify()
11.

What will be the output of the following PHP code? If say date is 22/06/2013.$?

A. 30
B. 22
C. JUNE
D. 2013
Answer» B. 22
12.

Among the four PHP DateTimeZone classes given below how many are nonstatic?1. _construct()2. getName()3. getOffset()4. getTransitions()$?

A. 1
B. 2
C. 3
D. 4
Answer» E.
13.

How many constants does the DateTime class have?$?

A. 8
B. 9
C. 10
D. 11
Answer» E.
14.

The date() function returns ___ representation of the current date and/or time.?

A. Integer
B. String
C. Boolean
D. Float
Answer» C. Boolean
15.

Which function displays the web page’s most recent modification date?$

A. lastmod()
B. getlastmod()
C. last_mod()
D. get_last_mod()
Answer» C. last_mod()
16.

Among the four PHP DateTimeZone classes given below how many are static?1. listAbbreviations()2. getName()3. getOffset()4. listIdentifiers()

A. 1
B. 2
C. 3
D. 4
Answer» C. 3
17.

What will be the output of the following PHP code?

A. TRUE
B. FALSE
C. Valid
D. Invalid
Answer» E.
18.

................Checks a date for numeric validity.

A. check_date
B. verifydate
C. Verify_date
D. checkdate
Answer» E.
19.

................ Formats a local time or date according to locale settings.

A. strftime
B. strgtime
C. strhtime
D. stritime
Answer» B. strgtime
20.

What will the following script output?

A. 0:00:00
B. 12:00:00
C. 00:i:00
D. 12:i:00
E. -1
Answer» D. 12:i:00
21.

The ......... function parses an English textual date or time into a Unix timestamp.

A. strtodate()
B. stroftime()
C. strtotime()
D. str_to_time()
Answer» D. str_to_time()
22.

.......... Returns the time of sunrise for a given day / location.

A. datesunrise()
B. date_sunrise()
C. date-sunrise()
D. date.sunrise()
Answer» C. date-sunrise()
23.

What would happen if the following script were run on a Windows server set to Moscow, Russia’s time zone?$

A. It would output the number 0
B. It would output the number -1
C. It would output the number 1
D. It would raise an error
E. It would output nothing
Answer» C. It would output the number 1
24.

The getdate() function returns

A. An integer
B. A floating-point number
C. An array
D. A string
E. A Boolean
Answer» D. A string
25.

You must make a call to ................... to specify what time zone you want calculations to take place in before calling any date functions.

A. date_default_timezone_set()
B. datedefault_timezone_set()
C. date_defaulttimezone_set()
D. date_default_timezoneset()
Answer» B. datedefault_timezone_set()
26.

What is the difference, in seconds, between the current timestamp in the GMT time zone and the current timestamp in your local time zone?

A. It depends on the number of hours between the local time zone and GMT
B. There is no difference
C. The two will only match if the local time zone is GMT
D. The two will never match
E. None of the above
Answer» C. The two will only match if the local time zone is GMT
27.

Which of the following functions do not return a timestamp?1. time()2. date()3. strtotime()4. localtime()5. gmmktime()

A. Option 1 and 5
B. Option 2 and 4
C. Option 1 and 4
D. Option 2 and 4
Answer» E.