Try to answer these 1000+ PHP MCQs and check your understanding of the PHP subject. Scroll down and let's begin!
A. false
B. " "
C. true
D. an error
A. Traits are class interfaces.
B. Traits are all of these things.
C. Traits allow code reuse without direct inheritance.
D. Traits allow multiple inheritance for classes.
A. backtrace_print
B. print_backtrace
C. backtrace
D. debug_backtrace_print
E. debug_print_backtrace
A. literally except for variables which are expanded
B. literally
C. escape sequences are interpreted
D. None of these
A. Only use the closing tag when short tags are enabled.
B. End all PHP files with '?>'.
C. Omit the closing tag when the file contains only PHP code.
D. There is no recommendation.
A. FALSE FALSE FALSE
B. TRUE FALSE FALSE
C. TRUE TRUE TRUE
D. fatal error when using isset on an array
E. TRUE FALSE TRUE
A. fopen("myFile", "wa")
B. fopen("myFile", "a")
C. fopen("myFile", "r+")
D. fopen("myFile", "w")
A. strtoupper()
B. ucfirst()
C. caps()
D. ucwords()
A. $greet $World;
B. PHP does not support this syntax.
C. $greet('World');
A. "new_value"
B. "old_value"
C. Fatal error, as the variable used in foreach is read-only
A. $class::function()
B. class->function()
C. class.function()
D. $class->function()
E. class::function
A. headers_sent()
B. sent()
C. http_response_code()
D. header()
A. single quoted strings cannot contain line breaks
B. variables names will not be expanded in double quotes
C. variable names will be expanded in double quotes
D. double quoted strings cannot contain line breaks
A. implode(' ',array($s1,$s2))
B. "{$s1} {$s2}"
C. $s1.$s2
D. $s1 + $s2
A. expression.
B. variable.
C. property.
D. argument.
A. $fast, $warp
B. $fast, $superSpeed, $ultraSonic
C. $fast
D. $superSpeed, $ultraSonic
E. $fast, $superSpeed, $ultraSonic, $warp
A. All of these
B. dollar sign($)
C. percent(%)
D. underscore(_)
A. Five
B. One
C. Two
D. More than two
E. None
A. $aVaR
B. ${“MyVar”}
C. $10_var
D. $_10
A. 2I
B. 67
C. P
D. &
A. PHP statement.
B. All of these
C. PHP array.
D. PHP function.
A. 2
B. 4
C. 3
D. 5
E. 1
A. Key
B. Textual
C. Associative
D. All of these
A. bool(false)
B. int(5)
C. bool(true)
D. string(1) "5"
A. $arr = implode('-', $str); $arr = implode('.', $arr[0]);
B. You can't
C. $arr = explode('-', $str); $arr = explode('.', $arr[0]);
D. $arr = str_replace('-', '', $str);
A. mt_random()
B. unpack()
C. php_create_user()
D. uniqid()
A. It is a library that gives the PHP the capability to access and create virtual domains. - (Generated Domain)
B. It is a library that gives the PHP the capability to create and manipulate image files. - (Gif Draw)
C. it's add a dozen of special new $_GLOBAL variables that gives principally informations on the user (localization, common social media cookies, etc...) - (Global iDentification)
A. fastest faster
B. fastest fastest
C. faster faster
D. faster fastest
A. method
B. protected
C. function
D. public
A. session_pw
B. session_destroy
C. session_decode
D. session_id
A. Function
B. Element
C. Parameters
D. String
A. E_ERROR
B. E_WARNING
C. ERROR
D. E_NOTICE
A. isset()
B. array_key_exists()
C. element()
D. for_each()
A. mysql_real_escape_string()
B. mysql_escape()
C. escape_mysql_string()
D. None of the above
E. mysqlescapethisstring()
A. awalk()
B. asort()
C. sort()
D. array_alpha()
A. $var = (bool)$var;
B. $var = ($var == $var);
C. Both are valid statements.
D. It's not possible to typecast variables like this.
A. ftp_chmod()
B. ftp_login()
C. ftp_connect()
D. ftp_chdir()
E. ftp_mkdir()
A. Array
B. 0
C. 2
D. 3
A. queries available in PHP.
B. database extensions available in PHP.
C. form extensions available in PHP
D. All of these
A. printf("Hello %s", $name);
B. print("Hello %s", $name);
C. echo("Hello %s", $name);
D. output("Hello %s", $name);
A. lib
B. blob
C. bin
D. blurb
A. str_to_time()
B. strtodate()
C. strtotime()
D. stroftime()
A. True
B. False
A. My name is OConnor.
B. My name is O'Connor.
C. None of these
D. My name is O\'Connor.
A. remove
B. clearfile
C. delete
D. unlink
A. remove_html_php()
B. tag_remove()
C. remove_tags()
D. strip_tags()
A. aa
B. PHP Parse error
C. truea
D. a
A. integer
B. double
C. strings
D. float
A. syntax error
B. falsefalse
C. true
D. false
E. None of the these
A. Function
B. Class
C. Exception
D. Conditional
A. private
B. protected
C. $this
D. public
A. All listed methods are valid
B. /* Comment code here */
C. // Comment code here
D. # Comment code here
A. TRC
B. STMP
C. PDO
D. POP
A. kill()
B. break()
C. exit()
D. halt()
E. eval()
A. print_var()
B. display_var()
C. output()
D. var_dump()
A. htmlentities()
B. ampersand()
C. transform()
D. convert()
A. array_combine()
B. combine()
C. array2()
D. $array()
A. They are case-sensitive by default.
B. They cannot be changed.
C. They cannot contain an array.
D. All of these.
A. identify a user.
B. create client side scripts.
C. validate input fields.
D. check for SQL injections.
A. retail computer computer
B. retail advertising computer
C. retail retail retail
D. retail retail computer
A. False
B. True
A. arithmetic operator
B. comparison operator
C. assignment operator
D. logical operator
A. $a = $b
B. $a === $b
C. None of these
D. $a == $b
A. array_rshuffle()
B. array_rchunk()
C. array_rand_pop()
D. array_rand()
E. array_diff_key()
A. ftp_chdir()
B. ftp_create_dir()
C. ftp_mkdir()
D. ftp_make_dir()
A. substr()
B. chunk_split()
C. parse_str()
D. str()
A. hELLO
B. HELLO
C. hellO
D. None of these
E. hello
A. $_SERVER['BROWSER_DETAIL']
B. $_SERVER['HTTP_AGENT']
C. $_SERVER['BROWSER_NAME']
D. $_SERVER['HTTP_USER_AGENT']
A. True
B. Only when posted with AJAX
C. False
D. Only when posted by a form
A. php.org
B. php.net
C. php.com
D. php.edu
E. php.us
A. Count number of rows in result of MySql Query.
B. Get all rows contain numbers.
C. Get all columns with numeric data.
D. Count number of columns in MySql Table.
E. Count number of characters in single row of MySql Query result.
A. All of these
B. "Hello there"
C. <<<EOD Hello there EOD;
D. 'Hello there'
A. phpAll();
B. phpNotice();
C. phpinfo();
D. phpsearch();
E. phpconfig();
A. plus(+)
B. dot(.)
C. decrement(--)
D. minus(-)
A. $variable.value = 'value';
B. $variable.['value'] = 'value';
C. $variable->value = 'value';
D. $variable['value'] = 'value';
E. $variable[value] = 'value';
A. class MyClass parent BaseClass {
B. class MyClass extends BaseClass {
C. class MyClass inherits BaseClass {
D. class MyClass includes BaseClass {
E. class MyClass using BaseClass {
A. $_ALL
B. $_REQUEST
C. $_MERGE
D. $_INCLUDE
A. No
B. Yes
C. Depends on the Operating System
A. regex method for an object.
B. class for the object.
C. constructor for an object.
D. pseudo element for an object.
A. Prototype
B. Type
C. Object
D. Instance
A. classes
B. attributes
C. variables
D. ID's
A. $x[] = "true";
B. $x = "true";
C. $x = true;
A. \r
B. \n
C. \"
D. All of these
A. Yes
B. No
A. count($a)
B. strlen($a)
C. len($a)
D. chr($a)
E. sizeof($a)
A. ceil()
B. max()
C. min()
D. bottom()
A. public my_function();
B. private my_function();
C. $this->my_function();
D. $this.my_function();
E. $this( my_function() );
A. ctrl alt delete
B. All of these
C. substr()
D. strpos()
A. subscript
B. index
C. values
D. keys
A. print
B. send
C. echo
D. printf
A. Inserts HTML line breaks (<BR />) before all newlines in a string.
B. Inserts HTML line breaks (<P />) before all newlines in a string.
C. Inserts HTML line breaks (<NL/>) before all newlines in a string.
D. Inserts HTML line breaks (<HR />) before all newlines in a string.
A. 3
B. 2
C. 5
D. 4
A. $_DIR
B. $_UPLOADED_FILES
C. $_SERVER
A. haystack()
B. strrpos()
C. split()
D. pos()
A. htaccess file.
B. php.ini file.
C. php.inc file.
D. machine.config file.
A. modify()
B. try / catch
C. E_STRICT
D. session();
A. preg_match()
B. regex()
C. test()
D. str()
A. session_start(); unset_session();
B. begin_session(); end_session();
C. start_session(); session_explode();
D. session_start(); session_destroy();
E. start_session(); end_session();
A. $my-Var
B. $my_Var
C. $myVar
D. $myvar
A. Both // and /* */
B. /* */
C. //
D. None of these