RSS

PHP - 4

Question ID 1

Choose the selection that best matches the following statements:
PHP is a _____ scripting language based on the ____ engine. It is primarily used to
develop dynamic _____ content, although it can be used to generate ____ documents
(among others) as well.
•             Dynamic, PHP, Database, HTML
•             Embedded, Zend, HTML, XML
•             Perl-based, PHP, Web, Static
•             Embedded, Zend, Docbook, MySQL
•             Zend-based, PHP, Image, HTML
•             I don’t know

Question ID 2

Which of the following tags is the valid way to begin and end a PHP code block?
•             <% %>
•             <? ?>
•             <! !>
•             <?php ?>
•             I don’t know

Question ID 3

Which of the following is not valid PHP code?
•             $_10
•             ${“MyVar”}
•             &$something
•             $10_somethings
•             $aVaR
•             I don’t know

Question ID 4

What is displayed when the following script is executed?
<?php

define(myvalue, "10");

$myarray[10] = "Dog";

$myarray[] = "Human";

$myarray['myvalue'] = "Cat";

$myarray["Dog"] = "Cat";

print "The value is: ";

print $myarray[myvalue]."n";

?>
•             The value is: Dog
•             The value is: Cat
•             The value is: Human
•             The value is: 10
•             Dog
•             I don’t know

Question ID 5

What is the difference between print() and echo()?
•             print() can be used as part of an expression, while echo() can’t
•             echo() can be used as part of an expression, while print() can’t
•             echo() can be used in the CLI version of PHP, while print() can’t
•             print() can be used in the CLI version of PHP, while echo() can’t
•             There’s no difference: there are alias
•             I don’t know

Question ID 6

Which language construct can best represent the following series of if conditionals?
<?php

if($a == 'a') {

somefunction();

} else if ($a == 'b') {

anotherfunction();

} else if ($a == 'c') {

dosomething();

} else {

donothing();

}

?>
•             A switch statement without a default case
•             A recursive function call
•             A while statement
•             It is the only representation of this logic
•             A switch statement using a default case
•             I don’t know

Question ID 7

What is the best way to iterate through the $myarray array, assuming you want to modify the value of each element as you do?
<?php

$myarray = array ("My String",

"Another String",

"Hi, Mom!");

?>
•             Using a for loop
•             Using a foreach loop
•             Using a while loop
•             Using a do…while loop
•             There is no way to accomplish this goal
•             I don’t know

Question ID 8

What is the value displayed when the following is executed? Assume that the code was
executed using the following URL:
testscript.php?c=25
<?php

function process($c, $d = 25)

{

global $e;

$retval = $c + $d - $_GET['c'] - $e;

return $retval;

}

$e = 10;

echo process(5);

?>
•             25
•             -5
•             10
•             5
•             I don’t know

Question ID 9

Run-time inclusion of a PHP script is performed using the ________ construct, while
compile-time inclusion of PHP scripts is performed using the _______ construct.
•             include_once, include
•             require, include
•             require_once, include
•             include, require
•             All of the above are correct
•             I don’t know

Question ID 10

How does the identity operator === compare two values?
•             It converts them to a common compatible data type and then compares the resulting values
•             It returns True only if they are both of the same type and value
•             If the two values are strings, it performs a lexical comparison
•             It bases its comparison on the C strcmp function exclusively
•             It converts both values to strings and compares them
•             I don’t know

Question ID 11

How can a script come to a clean termination?
•             When exit() is called
•             When the execution reaches the end of the current file
•             When PHP crashes
•             When Apache terminates because of a system problem
•             I don’t know

Question ID 12

Which function does return the number of seconds elapsed since the 1st January 1970?
•             time()
•             timestamp()
•             mktime()
•             microtime()
•             I don’t know

Question ID 13

In which array are the cookies sent by the browser?
•             $COOKIES
•             $HTTP_COOKIES
•             $_COOKIE
•             $HTTP_COOKIES_VARS
•             I don’t know

Question ID 14

How to sort an array by key?
•             $a = ksort($a);
•             ksort($a)
•             $a = rsort($a);
•             rsort($a);
•             I don’t know

Question ID 15

How to define a constant in PHP?
•             set(‘MY_CONST’, 10);
•             set(‘MY_CONST’=10);
•             define(‘MY_CONST’, 10);
•             const $my_const = 10;
•             I don’t know

Question ID 16

What is PHP?
•             Page Helper Process
•             Programming Home Pages
•             PHP: Hypertext Preprocessor
•             I don’t know

Question ID 17

How to get the length of an ANSI string using PHP?
•             strlen()
•             strlength()
•             length()
•             substr()
•             size()
•             I don’t know

Question ID 18

How many times the following loop will be executed?
<?php

for($i=0 ; $i<=3 ; $i++ ) { echo $i; }

?>
•             2
•             3
•             4
•             0, there is a parse error
•             I don’t know

Question ID 19

How to count the number of elements in an array using PHP?
•             size($a);
•             count($a);
•             countOf($a);
•             length($a);
•             I don’t know

Question ID 20

How to connect to a MySQL database in PHP?
•             connect_mysql(“localhost”);
•             mysql_open(“localhost”);
•             dbopen(“localhost”);
•             mysql_connect(“localhost”);
•             mysql_select_db();
•             I don’t know

Question ID 21

All variables in PHP start with which symbol?
•             &
•             $
•             !
•             _
•             I don’t know

Question ID 22

How do you get information from a form that is submitted using the “get” method?
•             Request.QueryString;
•             $_GET[];
•             Request.Form;
•             I don’t know

Question ID 23

When using the POST method, variables are displayed in the URL:
•             True
•             False
•             I don’t know

Question ID 24

In PHP you can use both single quotes ( ‘ ‘ ) and double quotes ( ” ” ) for strings:
•             True
•             False
•             I don’t know

Question ID 25

Include files must have the file extension “.inc”
•             True
•             False
•             I don’t know

Question ID 26

What is the correct way to create a function in PHP?
•             create myFunction()
•             new_function myFunction()
•             function myFunction()
•             myFunction()
•             I don’t know

Question ID 27

What is the correct way to add 1 to the $count variable?
•             $count =+1;
•             ++count;
•             $count++;
•             count++;
•             I don’t know

Question ID 28

What is a correct way to add a comment in PHP?
•             /*…*/
•             <!–…–>
•             *…*
•             <comment>…</comment>
•             I don’t know

Question ID 29

In PHP 5, MySQL support is enabled by default:
•             True
•             False
•             I don’t know

Question ID 30

What does SQL stand for?
•             Strong Question Language
•             Structured Question Language
•             Structured Query Language
•             I don’t know

Question ID 31

Which SQL statement is used to extract data from a database?
•             EXTRACT
•             OPEN
•             GET
•             SELECT
•             I don’t know

Question ID 32

Which SQL statement is used to update data in a database?
•             SAVE
•             MODIFY
•             SAVE AS
•             ALTER
•             UPDATE
•             I don’t know

Question ID 33

Which SQL statement is used to delete data from a database?
•             REMOVE
•             DELETE
•             COLLAPSE
•             ALTER
•             I don’t know

Question ID 34

Which SQL statement is used to insert new data in a database?
•             INSERT IN
•             INSERT INTO
•             INSERT NEW
•             ALTER
•             I don’t know

Question ID 35

With SQL, how do you select all the columns from a table named “Persons”?
•             SELECT * FROM Persons
•             SELECT Persons
•             SELECT [all] FROM Persons
•             SELECT *.Persons
•             I don’t know

Question ID 36

With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” starts with an “a”?
•             SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
•             SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
•             SELECT * FROM Persons WHERE FirstName=’%a%’
•             SELECT * FROM Persons WHERE FirstName=’a’
•             I don’t know

Question ID 37

Which SQL statement is used to return only different values?
•             SELECT UNIQUE
•             SELECT DIFFERENT
•             SELECT DISTINCT
•             I don’t know

Question ID 38

Which SQL keyword is used to sort the result-set?
•             ORDER
•             ORDER BY
•             SORT
•             SORT BY
•             I don’t know

Question ID 39

With SQL, how can you insert a new record into the “Persons” table?
•             INSERT VALUES (‘Jimmy’, ‘Jackson’) INTO Persons
•             INSERT INTO Persons VALUES (‘Jimmy’, ‘Jackson’)
•             INSERT (‘Jimmy’, ‘Jackson’) INTO Persons
•             I don’t know

Question ID 40

Inside which HTML element do we put the JavaScript?
•             <js>
•             <scripting>
•             <javascript>
•             <script>
•             I don’t know

Question ID 41

What is the correct syntax for referring to an external script called “xxx.js”?
•             <script href=”xxx.js”>
•             <script>
•             <script src=”xxx.js”>
•             I don’t know

Question ID 42

An external JavaScript must contain the <script> tag
•             True
•             False
•             I don’t know

Question ID 43

How do you write “Hello World” in an alert box in JavaScript?
•             alertBox(“Hello World”)
•             alertBox=”Hello World”
•             msgBox(“Hello World”)
•             alert(“Hello World”)
•             I don’t know

Question ID 44

How do you create a javascript function?
•             function myFunction()
•             function=myFunction()
•             function:myFunction()
•             I don’t know

Question ID 45

How do you call a function named “myFunction” in JavaScript?
•             call myFunction
•             call myFunction()
•             myFunction()
•             function myFunction()
•             I don’t know

Question ID 46

How do you write a conditional statement for executing some statements only if “i” is equal to 5?
•             if i==5 then
•             if i=5
•             if (i==5)
•             if i=5 then
•             I don’t know

Question ID 47

How do you write a conditional statement for executing some statements only if “i” is NOT equal to 5 (in Javascript) ?
•             if <>5
•             if (i != 5)
•             if (i <> 5)
•             if =! 5 then
•             I don’t know

Question ID 48

How do you round the number 7.25, to the nearest whole number?
•             Math.round(7.25)
•             Math.rnd(7.25)
•             round(7.25)
•             rnd(7.25)
•             I don’t know

Question ID 49

What combination of technologies gives AJAX its name?
•             ASP and XAML
•             Asynchronous JavaScript and XML
•             Autonomic Computing and DHTML
•             ASP and XML
•             I don’t know

Question ID 50

Can AJAX be synchronous?
•             True
•             False
•             I don’t know

Question ID 51

Which one of these technologies is NOT used in AJAX?
•             JSON
•             XML
•             DHTML
•             DOM
•             Flash
•             I don’t know

Question ID 52

Ajax is a programming language
•             True
•             False
•             I don’t know

Question ID 53

The XMLHttpRequest object can be used on subdomain1.mysite.com to request a page located at subdomain2.mysite.com according to the specification.
•             True
•             False
•             I don’t know

Question ID 54

What will be displayed in the following case:
- No content has been previously sent to the client
- You decide to use in your script the PHP header() function to send a 404 error code
- You write exit(); just after this function.
•             A blank page with “HTTP/1.1 404 Not Found”
•             A PHP error
•             A blank page
•             The normal page
•             A customized error page
•             I don’t know

Question ID 61

What is the effect of the “return” instruction when used in a included PHP script?
•             Return to the parent script while ignoring the rest of the included file
•             A PHP error
•             The script stops (same as exit());
•             Nothing, it is ignored
•             It depends if the file is included with include() or require()
•             I don’t know

Question ID 62

Which function flush the output buffer and turn off output buffering?
•             ob_flush()
•             ob_end_flush()
•             ob_get_flush()
•             ob_end_clean()
•             I don’t know

Question ID 63

How are session variables accessed?
•             Through $_GET
•             Through $_POST
•             Through $_REQUEST
•             Through $_SESSIONS
•             None of the above
•             I don’t know

Question ID 64

Which of these PHP functions or codes is used to send cookie to the client?
•             cookie()
•             set_cookie()
•             setcookie()
•             $_COOKIE
•             None of the above
•             I don’t know

Question ID 65

If no expiration time is explicitly set for a cookie, what happens to it?
•             It expires right away
•             It never expires
•             It is not set
•             It expires at the end of the user’s browser session
•             It expires only if the script doesn’t create a server-side session
•             I don’t know

Question ID 66

Consider the following form and subsequent script. What will the script print out if the user types the word “php” and “great” in the two text boxes respectively?
<form action="index.php" method="post">

<input name="element[]">

<input name="element[]">

</form>

<?php

echo $_GET['element'];

?>
•             Nothing
•             Array
•             A notice
•             phpgreat
•             greatphp
•             I don’t know

Question ID 67

In an HTTPS transaction, how are URLs and query strings passed from the browser to the
web server?
•             They are passed in clear text, and the subsequent transaction is encrypted
•             They are encrypted
•             The URL is left in clear text, while the query string is encrypted
•             The URL is encrypted, while the query string is passed in clear text
•             To ensure its encryption, the query string is converted into a header and passed along with the POST information
•             I don’t know

Question ID 60

The index.php page contains the following code:
<?php

$a = 'a'.file_exists(__FILE__);

$a1 = 'wiki';

$a2 = 'kiwi';

echo ${$a};

?>
What is displayed on this page?
•             A blank page
•             kiwi
•             wiki
•             A PHP error
•             None of the above
•             I don’t know

Question ID 69

What will the following script output?
<?php

ob_start();

for ($i = 0; $i < 10; $i++) {

echo $i;

}

$output = ob_get_contents();

ob_end_clean();

echo $ouput;

?>
* 12345678910
* 1234567890
* 0123456789
* Nothing
* A notice
* I don’t know

Question ID 70

By default, PHP stores session data in:
•             The filesystem
•             A database
•             Virtual memory
•             Shared memory
•             None of the above
•             I don’t know

Question ID 71

Assuming that the client browser is never restarted, how long after the last access will a session “expire” and be subject to garbage collection?
•             After exactly 1,440 seconds
•             After the number of seconds specified in the session.gc_maxlifetime INI setting
•             It will never expire unless it is manually deleted
•             It will only expire when the browser is restarted
•             None of the above
•             I don’t know

Question ID 72

Array values are keyed by ______ values (called indexed arrays) or using ______ values (called associative arrays). Of course, these key methods can be combined as well.
•             Float, string
•             Positive number, negative number
•             Even number, string
•             String, Boolean
•             Integer, string
•             I don’t know

Question ID 73

Consider the following array, called $multi_array. How would the value cat be referenced within the $multi_array array?
<?php

$multi_array = array("red",

"green",

42 => "blue",

"yellow" => array("apple",

9 => "pear",

"banana",

"orange" => array("dog",

"cat",

"iguana")

)

);

?>
•             $multi_array['yellow']['apple'][0]
•             $multi_array['blue'][0]['orange'][1]
•             $multi_array[3][3][2]
•             $multi_array['yellow']['orange']['cat']
•             $multi_array['yellow']['orange'][1]
•             I don’t know

Question ID 74

What will the $array array contain at the end of the execution of the following script?
<?php

$array = array ('1', '1');

foreach ($array as $k => $v) {

$v = 2;

}

?>
•             array (’2′, ’2′)
•             array (’1′, ’1′)
•             array (2, 2)
•             array (Null, Null)
•             array (1, 1)
•             I don’t know

Question ID 75

Assume you would like to sort an array in ascending order by value while preserving key
associations. Which of the following PHP sorting functions would you use?
•             ksort()
•             asort()
•             krsort()
•             sort()
•             usort()
•             I don’t know

Question ID 76

What will the following script output?
<?php

$array = array (3 => 'a', '1b' => 'b', 'c', 'd');

echo ($array[1]);

?>
•             1
•             b
•             c
•             A warning.
•             A notice.
•             I don’t know

Question ID 77

What elements will the following script output?
<?php

$array = array (true => 'a', 1 => 'b');

var_dump ($aray);

?>
•             1 => ‘b’
•             True => ‘a’, 1 => ‘b’
•             0 => ‘a’, 1 => ‘b’
•             None
•             It will output NULL
•             I don’t know

Question ID 78

Which of the following will not combine strings $s1 and $s2 into a single string?
•             $s1 + $s2
•             “{$s1}{$s2}”
•             $s1.$s2
•             implode(”, array($s1,$s2))
•             All of the above combine the strings
•             I don’t know

Question ID 79

Given a variable $email containing the string user@example.com, which of the following statements would extract the string example.com?
•             substr($email, strpos($email, “@”));
•             strstr($email, “@”);
•             strchr($email, “@”);
•             substr($email, strpos($email, “@”)+1);
•             strrpos($email, “@”);
•             I don’t know

Question ID 80

Given a comma-separated list of values in a string, which function from the given list can create an array of each individual value with a single call?
•             strstr()
•             Cannot be done with a single function
•             extract()
•             explode()
•             strtok()
•             I don’t know

Question ID 81

What will be the output of the following script?
<?php

$s = '12345';

$s[$s[1]] = '2';

echo $s;

?>
•             12345
•             12245
•             22345
•             11345
•             Array
•             I don’t know

Question ID 82

What happens if you add a string to an integer using the + operator?
•             The interpreter outputs a type mismatch error
•             The string is converted to a number and added to the integer
•             The string is discarded and the integer is preserved
•             The integer and string are concatenated together in a new string
•             The integer is discarded and the string is preserved
•             I don’t know

Question ID 83

What does the built-in delete function do?
•             It deletes a file
•             It deletes a directory
•             It unsets a variable
•             It removes a database row
•             This function does not exist!
•             I don’t know

Question ID 84

Consider the following script. Which PHP5 function best approximates its behaviour?
<?php

function my_funct ($file_name, $data)

{

$f = fopen ($file_name, 'w');

fwrite ($f, $data);

fclose ($f);

}

?>
•             file_get_contents()
•             file_put_contents()
•             There is no equivalent function in PHP
•             file()
•             fputs()
•             I don’t know

Question ID 85

Which of the following definitions describes the time function?
•             It returns the number of seconds since the UNIX epoch
•             It calculates the time elapsed since the UNIX epoch and expresses it as an integer number
•             It returns the current time measured in the number of seconds since January 1, 1970 00:00:00 GMT
•             All of the above
•             I don’t know

Question ID 86

The date() function returns ______________.
•             An integer
•             A floating-point number
•             An array
•             A string
•             None of the above
•             I don’t know

Question ID 87

What does an “inner join” construct do?
•             It joins two tables together into a third permanent table based on a common column
•             It creates a result set based on the rows in common between two tables
•             It creates a result set based on the rows based on one table
•             It creates a result set by joining two tables together and taking all the rows in
common plus the rows belonging to one of the tables
•             None of the above
•             I don’t know

Question ID 88

Which of the following is true?
•             Indexing can speed up the insertion of new rows in a table
•             A good indexing strategy helps prevent cross-site scripting attacks
•             Indexes should be designed based on the database’s actual usage
•             Deleting a row from a table causes its indexes to be dropped
•             Indexes are necessary on numeric rows only
•             I don’t know

Question ID 89

What does the DESC keyword do in the following query?
SELECT *
FROM MY_TABLE
WHERE ID > 0
ORDER BY ID, NAME DESC
•             It causes the dataset returned by the query to be sorted in descending order
•             It causes rows with the same ID to be sorted by NAME in ascending order
•             It causes rows with the same ID to be sorted by NAME in descending order
•             It causes rows to be sorted by NAME first and then by ID
•             It causes the result set to include a description of the NAME field
•             I don’t know

Question ID 90

Which of the following correctly identify the requirement for a column to be part of the result set of a query that contains a GROUP BY clause?
•             The column must be indexed
•             The column must be a unique key
•             The column must contain an aggregate value and be included in the GROUP BY clause
•             The column must be a primary key
•             The column must not contain NULL values
•             I don’t know

Question ID 91

Which of the following is the single most important technique that can help you make your PHP application secure from external intrusion?
•             Having strong encryption algorithms
•             Protecting database passwords
•             Using SSL whenever possible
•             Validating all inputs
•             Only using input from trusted sources
•             I don’t know

Question ID 92

Although not necessarily foolproof, what of the following can help identify and prevent potential security risks in your code?
•             Being aware of potential security issues as documented in the PHP manual.
•             Logging all circumstances in which your script data validation fails
•             Keeping up to date with the latest versions of PHP, especially those that contain security fixes
•             When using third-party PHP packages, being aware of any security holes found in them and keeping fixes up to date
•             All of the above
•             I don’t know

Question ID 93

When an error occurs on your web site, how should it be treated?
•             An error message should be displayed to the user with technical information regarding its apparent cause, so that the web master can address it
•             The error should be logged, and a polite message indicating a server malfunction should be presented to the user
•             An error message with technical information regarding the error should be displayed so that the user can send it to the webmaster and the error should be logged
•             Errors should redirect the users to the home page, as to not indicate a malfunction
•             None of the above
•             I don’t know

Question ID 94

What does an opcode cache do?
•             It compiles scripts into binary objects to make them run faster
•             It replaces the Zend Engine to provide a faster interpreter
•             It caches a script’s output to improve its performance
•             It improves performance by caching the intermediate code produced by the parser
•             It caches a script in memory, thus eliminating the need for reloading it from disk at every iteration
•             I don’t know

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comments:

Post a Comment