wayground logo

Lembar Kerja Gratis yang Dapat Dicetak

Ukuran huruf

S
M
L
XL
Lembar kerja

PHP Class Test

Total soal: 62

Worksheet time: 34mins

Nama
Kelas
Tanggal
1.

Which function is used to open a file

a)

fopen(filename, mode of opening file)

b)

fopen(file, mode of reading file)

c)

open(filename, mode of opening file)

d)

none

2.

if there is fopen function in program then there should always be

a)

fread()_

b)

fwrite()

c)

fclose()

d)

none

3.

!feof stands for

a)

file end of file

b)

not file end of file

c)

exlamatory file end of file

d)

none

4.

fread() reads contents of file

a)

word by word till eof

b)

paragraph by paragraph till end of file

c)

line by line till eof

d)

none

5.

When fwrite is used on already existing file the what will happen

a)

new contents added to previous file contents

b)

previous file contents deleted and new contents added

c)

error displayed

d)

none

6.

when you try to open a non existing file then

a)

error

b)

statement file not available

c)

question should i open new file in given name popped

d)

new file will be created in the given name

7.

Can values got from forms in html be given to php

a)

sometimes

b)

yes

c)

no

d)

none

8.

PHP is an acronym for "PHP: Hypertext Preprocessor"

a)

True

b)

False

9.

PHP is a widely-used, open source scripting language

a)

True

b)

False

10.

PHP files can contain text, HTML, CSS, JavaScript, and PHP code

a)

True

b)

False

11.

<!DOCTYPE html>

<html>

<body>


<?php

$color = "red";

echo "My car is " . $color . "<br>";

echo "My house is " . $COLOR . "<br>";

echo "My boat is " . $coLOR . "<br>";

?>


</body>

</html>

the result..?

a)

My car is red

My house is

My boat is

b)

My car is red

My house is

c)

My car is red

12.

<!DOCTYPE html>

<html>

<body>

<?php

// You can also use comments to leave out parts of a code line

$x = 5 /* + 15 */ + 5;

echo $x;

?>

</body>

</html>

the result..?

a)

10

b)

5

c)

15

13.

<!DOCTYPE html>

<html>

<body>


<?php

$txt = "Hello world!";

$x = 5;

$y = 10.5;


echo $txt;

echo "<br>";

echo $x;

echo "<br>";

echo $y;

?>


</body>

</html>

the result..?

a)

Hello world!

5

10.5

b)

Hello world!

c)

5

d)

10.5

14.

What is the correct way to create a function in PHP?

a)

new_function myFunction()

b)

create myFunction()

c)

function myFunction()  

15.

When using the POST method, variables are displayed in the URL:

a)

True

b)

False

16.

What is the correct way to open the file "time.txt" as readable?

a)

fopen("time.txt","r");  

b)

open("time.txt","read");

c)

open("time.txt");

17.

Write the code to output the value of the session variable "favcolor".

(a)  

18.

Create a session variable named "favcolor".

Write the correct answer for the blank box.

(a)  

19.

Where is your PHP project file located?

a)

C:\xampp\htdocs\

b)

C:\xampp\project\

c)

D:\xampp\htdocs\

20.

The default file extension for PHP files is __________.

a)

.html

b)

.php

c)

.css

d)

.java

21.

PHP syntax start and end with __________.

a)

<? php

//codes here

?>

b)

<? html

//codes here

?>

c)

<? head

//codes here

?>

22.

The MySQLi extension, the 'i' stands for __________.

a)

impress

b)

improved

c)

initial

23.

What is the step to create database?

a)

Open localhost/phpmyadmin/

b)

Open NetBeans/New Project/

c)

Open browser/Notepad++

24.

Which

one of the following statements instantiates the mysqli class?

a)

mysqli

= new mysqli()

b)

$mysqli

= new mysqli()

c)

$mysqli->new.mysqli()

d)

mysqli->new.mysqli()

25.

Which

one of the following statements is used to create a table?

a)

CREATE

TABLE table_name (column_name column_type);

b)

CREATE

table_name (column_type column_name);

c)

CREATE

table_name (column_name column_type);

d)

CREATE

TABLE table_name (column_type column_name);

26.

Which

one of the following databases has PHP supported almost since the beginning?

a)

Oracle

Database

b)

SQL

c)

SQL+

d)

MySQL

27.

Who is

the father of PHP?

a)

Rasmus

Lerdorf

b)

Willam

Makepiece

c)

Drek

Kolkevi

d)

List

Barely

28.

Which

of the following is a disadvantage of using JavaScript?

a)

Client-side

JavaScript does not allow the reading or writing of files.

b)

JavaScript

can not be used for Networking applications because there is no such support

available.

c)

JavaScript

doesn't have any multithreading or multiprocess capabilities.

d)

All of

the above.

29.

A

function in PHP which starts with __ (double underscore) is known as

__________

a)

Magic

Function

b)

Inbuilt

Function

c)

Default

Function

d)

User

Defined Function

30.

What is the function used to close DB Connection?

a)

close()

b)

exit()

c)

mysqli_exit()

d)

mysqli_close()

31.

What is the function used to display database connection related error?

a)

mysqli_db_error()

b)

mysqli_connect_db_error()

c)

mysqli_connect_error()

d)

mysqli_error()

32.

How do you get information from a form that is submitted using the "get" method?

a)

Request.QueryString;

b)

$_GET[];

c)

Request.Form;

33.

When using the POST method, variables are displayed in the URL:

a)

True

b)

False

34.

Which statement can be used to select the database?

a)

$mysqli=select_db('databasename');

b)

mysqli=select_db('databasename');

c)

mysqli->select_db('databasename');

d)

$mysqli->select_db('databasename');

35.

Which method is responsible for sending the query to the database?

a)

query()

b)

send_query()

c)

sendquery()

d)

query_send()

36.

Which will input data into a table?

a)

INSERT INTO table(name, height, weight) VALUES('strand', '6ft 2in', '165')

b)

INPUT INTO table(name, height, weight) VALUES('strand', '6ft 2in', '165')

c)

INSERT INTO table CATEGORIES(name, height, weight) VALUES('strand', '6ft 2in', '165')

d)

INSERT INTO table CATEGORIES(name, height, weight) ('strand', '6ft 2in', '165')

37.

Enter your Full Reg No

4 lines
38.

Which of the following symbol is used to add multiple line comments in PHP ?

a)

//

b)

/* */

c)

{{ }}

d)

{/ \}

39.

Which of the following is used to create a session?

a)

session_destroy() function

b)

session_start() function

c)

$_SESSION[]

d)

isset() function

40.

Which of the following is the use of strlen() function in PHP?

a)

The strlen() function returns both value and type of string

b)

The strlen() function returns the length of string

c)

The strlen() function returns the type of string

d)

The strlen() function returns the value of string

41.

Which of the following is used for concatenation in PHP?

a)

+ (plus)

b)

* (Asterisk)

c)

. (dot)

d)

append()

42.

Which of the following is the correct way to create a function in PHP?

a)

Create myFunction()

b)

New_function myFunction()

c)

function myFunction()

d)

None of the above

43.

Which of the following is the correct way of defining a variable in PHP?

a)

$variable name = value;

b)

$variable_name = value;

c)

$variable_name = value

d)

$variable name as value;

44.

Which of the following function is used to set cookie in PHP?

a)

createcookie()

b)

makecookie()

c)

set cookie()

d)

None of the above

45.

Which of the following is the correct way to create an array in PHP?

a)

$season = array["summer" , "winter" , "spring" , "autumn"];

b)

$season = array("summer" , "winter" , "spring" , "autumn");

c)

$season =( "summer" , "winter" , "spring" , "autumn");

d)

All of the above

46.

What will be the output of the following program?

<?php

$a = 15;

function show() {

$a = 20; echo "$a";

}

show();

echo "$a";

?>

a)

2020

b)

2015

c)

1515

d)

0

47.

How many Primary keys can have in a table?

a)

Only 1

b)

Only 2

c)

Depends on no of Columns

d)

Depends on DBA

48.

If we have not specified ASC or DESC after a SQL ORDER BY clause, the following is used by default

a)

DESC

b)

ASC

c)

There is no default value

d)

None of the mentioned

49.

Create a variable in php assign with the

a)

String

b)

const

c)

let

d)

$

50.

Use the correct function to output the number of items in an array.


$fruits = array("Apple", "Banana", "Orange");

a)

echo $fruits[0]

b)

echo $fruits["Apple"]

c)

echo count($fruits)

d)

echo $fruits[0][1]

51.

Write a correct syntax to include a file named "footer.php".

a)

include ("footer.php");

b)

import("footer.php");

c)

required("footer.php");

d)

export("footer.php");

52.

Assume we have a file named "webdict.txt", write the correct syntax to open and read the file content.

a)

readfile("webdict.txt")

b)

openfile("webdict.txt")

c)

writefile("webdict.txt")

d)

modifyfile("webdict.txt")

53.

Create a cookie named "username".

a)

setcookie = ("username", "John", time() + (86400 * 30), "/");

b)

setcookie("username", "John", time() + (86400 * 30), "/");

c)

session("username", "John", time() + (86400 * 30), "/");

d)

setsession("username", "John", time() + (86400 * 30), "/");

54.

A period of time during which a particular person, views a number of web pages at a particular machine is called as a

a)

session

b)

cookie

c)

parsing

55.

In PHP, cookies are set by using the

a)

setcookie() function

b)

set() function

c)

cookie_set() function

56.

Name, value, expire, path, httponly, domain, secure all of these are arguments of

a)

session()

b)

cookie()

c)

setcookie()

57.

Which two predefined variables are used to retrieve information from forms?

a)

$GET & $POST

b)

$_GET & $_POST

c)

&_GET & &_POST

58.

A cookie is often used to identify a

a)

USER

b)

BROWSER

c)

WEB PAGE

59.

5. Which is a small file that the server embeds on the user's computer

a)

SESSION

b)

COOKIE

c)

FILE

60.

Session variables are set with the PHP global variable

a)

$SESSION[]

b)

$_SESSION[]

c)

&SESSION

61.

If the directive session.cookie_lifetime is set to 3600, the cookie will live until ____________

a)

3600 sec

b)

3600 mint

c)

3600 hrs

62.

In POST method the results at a given moment cannot be

a)

SAVED

b)

MOVE

c)

BOOKMARKED