You are on page 1of 7

NASKAH UJIAN (ASSESSMENT)

PROGRAM STUDI MANAJEMEN INFORMATIKA


FAKULTAS ILMU TERAPAN - UNIVERSITAS TELKOM
SEMESTER GASAL TAHUN AKADEMIK 2017/2018
I. IDENTITAS MATA KULIAH
a. Kode/Nama Mata Kuliah : DPH2I4/Pemrograman Web Dasar
b. Assessment ke- : Satu
c. Kode Soal : C
d. Waktu Pengerjaan : 120 menit
e. Metode Pengerjaan : Tulis

II. PETUNJUK PENGERJAAN ASSESSMENT


a. Cantumkan identitas pada lembar jawaban.
b. Sifat ujian INDIVIDU dan dapat melihat catatan yang telah dipersiapkan (bukan buku atau
kode program dari komputer).
c. Kerjakan SEMUA soal yang tersedia.
d. Dilarang browsing dan menggunakan alat komunikasi selama assessment berlangsung.
e. Jika ada hal-hal yang kurang jelas dari butir soal yang disajikan, dapat ditanyakan pada
pengawas assessment.

1. What is the correct way to end a PHP statement?


a. New line
b. . ;
c.
d. </php>
2. What is the correct way to include the file "time.inc" ?
a. <!-- include file="time.inc" -->
b. <?php include "time.inc"; ?>
c. <?php include:"time.inc"; ?>
d. <?php include file="time.inc"; ?>
3. What is the correct way to create a function in PHP?
a. function myFunction()
b. new_function myFunction()
c. create myFunction()
4. Which superglobal variable holds information about headers, paths, and script locations?
a. $_SERVER
b. $_GET
c. $_SESSION
d. $_GLOBALS
5. What is the correct way to add 1 to the $count variable?
a. $count =+1
b. $count++;
c. ++count
d. count++;
6. The PHP syntax is most similar to:
a. VBScript
b. JavaScript
c. Perl and C
7. How do you get information from a form that is submitted using the "get" method?
a. Request.Form;
b. $_GET[];
c. Request.QueryString;
8. When using the POST method, variables are displayed in the URL:
a. False
b. True
9. In PHP you can use both single quotes ( ' ' ) and double quotes ( " " ) for strings:
a. True
b. False
10. Include files must have the file extension ".inc"
a. False
b. True
11. What is the correct way to add 1 to the $count variable?
a. $count =+1
b. $count++;
c. ++count
d. count++;
12. What is a correct way to add a comment in PHP?
a. /*...*/
b. *\...\*
c. <!--...-->
d. <comment>...</comment>
13. PHP can be run on Microsoft Windows IIS(Internet Information Server):
a. True
b. False
14. The die() and exit() functions do the exact same thing.
a. True
b. False
15. The setcookie() function must appear BEFORE the <html> tag.
a. False
b. True
16. In PHP, the only way to output text is with echo.
a. False
b. True
17. How do you create an array in PHP?
a. $cars = array("Volvo", "BMW", "Toyota");
b. $cars = array["Volvo", "BMW", "Toyota"];
c. $cars = "Volvo", "BMW", "Toyota";
18. The if statement is used to execute some code only if a specified condition is true
a. True
b. False
19. What will by displayed by the following script?
<?php
$s = '12345';
$s[$s[1]] = '2';
echo $s;
?>
a. 12345
b. 12245
c. 22345
d. 11345 
e. Array
20. What will by displayed by the following script :
$array = array (0.1 => 'a', 0.2 => 'b');
echo count ($array);
?>
a. 1
b. 2
c. 0
d. None
e. 0.3
21. Metode pengiriman data yang tidak dilewatkan pada URL menggunakan method..
a. POST              
b. DOWNLOAD
c. GET                 
d. IMG SRC
e. UPLOAD

22. Which of the following tags is not a valid way to begin and end a PHP code block?
a. <% %>
b. <?php ?>
c. <? ?>
d. <?= ?>
e. <!-- -->

23. What is displayed when the following script is executed?

<?php

define(pet, "4");
$mypet[4] = "Chicken";
$mypet[] = "Human";
$mypet ['pet'] = "Sheep";
$mypet ["Sheep"] = "Cat";
print "The value is: ";
print $ mypet[pet]."\n";

?>

a. The value is: Cat


b. The value is: Sheep
c. The value is: Human
d. The value is: Chicken
e. Sheep

24. What is the output of the following script?

<?php

$a = 10;
$b = 5;
$c = 4;
$d = 8;
$e = 1.0;
$b++;
$c=(--$a)+$b++;
$f = $c + $d * 2;
$g = $f % 10;

print $g;

?>

a. -1
b. 0
c. 1
d. 2
e. 3
25. Consider the following segment of code:

<?php

define("LIMIT", 2187);
$result= array();

for ($idx = 1; $idx < LIMIT; $idx *= 3)


{
$result[] = $idx;
}

echo "<pre>";
print_r($result);
echo "</pre>";

?>

What should go in the marked segment to produce the following array output?
Array
(
[0] => 1
[1] => 3
[2] => 9
[3] => 27
[4] => 81
[5] => 243
[6] => 729
)

a. foreach($result as $key => $val)


b. for($idx = 1; $idx < LIMIT; $idx *= 3)
c. for($idx *= 3; LIMIT >= $idx; $idx = 0)
d. while($idx < LIMIT) do $idx *= 3
e. while($idx *= 3)

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

function process($c, $d = 11)


{
if(!isset($_GET['c']))
$_GET['c']=1;

global $e;
$retval = $c + $d - $_GET['c'] - $e;
return $retval;
}
$e = 5;
echo process(7);

?>

a. -12
b. -1
c. 0
d. 1
e. 12
27. Which of the following is not valid PHP code?

a. $_999;
b. $10satu
c. ${“TestAja”}
d. &$testsatu
e. $ApasaRTF

28. How can the index.php script access the NIM or email form element of the following HTML form?
(Choose 2)

<form action="index.php" method="post">


<input type="text" name="NIM"/>
<input type="text" name="Email"/>
</form>

a. $_GET['email']
b. $_POST['email']
c. $_SESSION['NIM’]
d. $_REQUEST['NIM']
e. $_POST['text']

29. Consider the following form and subsequent script. What will the script print out if the user
types the word “poltek” and “student” in the two text boxes respectively?

<form action="" method="post">


<input type="text" name="variable[]">
<input type="text" name="variable[]">
<input type="submit" name="send">
</form>

<?php

echo $_GET[‘variable’];

?>

a. Nothing
b. Array
c. A notice
d. phpgreat
e. greatphp

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

<?php

$nested_array = array("white",
"green",
"black" => 67,
30 => "red",
"yellow" => array("durian",
50 => "banana",
"cat" => 40,
"purple" => array("dog","cat","iguana")
)
);
?>

a. $multi_array['yellow']['cat']
b. $multi_array[5][2]
c. $multi_array[4][3][1]
d. $multi_array['yellow']['purple']['cat']
e. $multi_array['yellow']['purple'][1]

Essay (40 Poin)


$data = array(
array('1' => 3, 5, '3' =>6),
array(3,8,1),
array('7'=>4, '8'=>4, 10),
);
array_pop($data);
$nilai = ($data[1][0] + $data[1][2]) % $data[0][2];
echo $nilai++;

What is the ourput of the above script?

You might also like