Ukuran huruf
Lembar kerjaPHP Class Test
Total soal: 62
Worksheet time: 34mins
Which function is used to open a file
fopen(filename, mode of opening file)
fopen(file, mode of reading file)
open(filename, mode of opening file)
none
if there is fopen function in program then there should always be
fread()_
fwrite()
fclose()
none
!feof stands for
file end of file
not file end of file
exlamatory file end of file
none
fread() reads contents of file
word by word till eof
paragraph by paragraph till end of file
line by line till eof
none
When fwrite is used on already existing file the what will happen
new contents added to previous file contents
previous file contents deleted and new contents added
error displayed
none
when you try to open a non existing file then
error
statement file not available
question should i open new file in given name popped
new file will be created in the given name
Can values got from forms in html be given to php
sometimes
yes
no
none
PHP is an acronym for "PHP: Hypertext Preprocessor"
True
False
PHP is a widely-used, open source scripting language
True
False
PHP files can contain text, HTML, CSS, JavaScript, and PHP code
True
False
<!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..?
My car is red
My house is
My boat is
My car is red
My house is
My car is red
<!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..?
10
5
15
<!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..?
Hello world!
5
10.5
Hello world!
5
10.5
What is the correct way to create a function in PHP?
new_function myFunction()
create myFunction()
function myFunction()
When using the POST method, variables are displayed in the URL:
True
False
What is the correct way to open the file "time.txt" as readable?
fopen("time.txt","r");
open("time.txt","read");
open("time.txt");
Write the code to output the value of the session variable "favcolor".
(a)
Create a session variable named "favcolor".
Write the correct answer for the blank box.
(a)
Where is your PHP project file located?
C:\xampp\htdocs\
C:\xampp\project\
D:\xampp\htdocs\
The default file extension for PHP files is __________.
.html
.php
.css
.java
PHP syntax start and end with __________.
<? php
//codes here
?>
<? html
//codes here
?>
<? head
//codes here
?>
The MySQLi extension, the 'i' stands for __________.
impress
improved
initial
What is the step to create database?
Open localhost/phpmyadmin/
Open NetBeans/New Project/
Open browser/Notepad++
Which
one of the following statements instantiates the mysqli class?
mysqli
= new mysqli()
$mysqli
= new mysqli()
$mysqli->new.mysqli()
mysqli->new.mysqli()
Which
one of the following statements is used to create a table?
CREATE
TABLE table_name (column_name column_type);
CREATE
table_name (column_type column_name);
CREATE
table_name (column_name column_type);
CREATE
TABLE table_name (column_type column_name);
Which
one of the following databases has PHP supported almost since the beginning?
Oracle
Database
SQL
SQL+
MySQL
Who is
the father of PHP?
Rasmus
Lerdorf
Willam
Makepiece
Drek
Kolkevi
List
Barely
Which
of the following is a disadvantage of using JavaScript?
Client-side
JavaScript does not allow the reading or writing of files.
JavaScript
can not be used for Networking applications because there is no such support
available.
JavaScript
doesn't have any multithreading or multiprocess capabilities.
All of
the above.
A
function in PHP which starts with __ (double underscore) is known as
__________
Magic
Function
Inbuilt
Function
Default
Function
User
Defined Function
What is the function used to close DB Connection?
close()
exit()
mysqli_exit()
mysqli_close()
What is the function used to display database connection related error?
mysqli_db_error()
mysqli_connect_db_error()
mysqli_connect_error()
mysqli_error()
How do you get information from a form that is submitted using the "get" method?
Request.QueryString;
$_GET[];
Request.Form;
When using the POST method, variables are displayed in the URL:
True
False
Which statement can be used to select the database?
$mysqli=select_db('databasename');
mysqli=select_db('databasename');
mysqli->select_db('databasename');
$mysqli->select_db('databasename');
Which method is responsible for sending the query to the database?
query()
send_query()
sendquery()
query_send()
Which will input data into a table?
INSERT INTO table(name, height, weight) VALUES('strand', '6ft 2in', '165')
INPUT INTO table(name, height, weight) VALUES('strand', '6ft 2in', '165')
INSERT INTO table CATEGORIES(name, height, weight) VALUES('strand', '6ft 2in', '165')
INSERT INTO table CATEGORIES(name, height, weight) ('strand', '6ft 2in', '165')
Enter your Full Reg No
Which of the following symbol is used to add multiple line comments in PHP ?
//
/* */
{{ }}
{/ \}
Which of the following is used to create a session?
session_destroy() function
session_start() function
$_SESSION[]
isset() function
Which of the following is the use of strlen() function in PHP?
The strlen() function returns both value and type of string
The strlen() function returns the length of string
The strlen() function returns the type of string
The strlen() function returns the value of string
Which of the following is used for concatenation in PHP?
+ (plus)
* (Asterisk)
. (dot)
append()
Which of the following is the correct way to create a function in PHP?
Create myFunction()
New_function myFunction()
function myFunction()
None of the above
Which of the following is the correct way of defining a variable in PHP?
$variable name = value;
$variable_name = value;
$variable_name = value
$variable name as value;
Which of the following function is used to set cookie in PHP?
createcookie()
makecookie()
set cookie()
None of the above
Which of the following is the correct way to create an array in PHP?
$season = array["summer" , "winter" , "spring" , "autumn"];
$season = array("summer" , "winter" , "spring" , "autumn");
$season =( "summer" , "winter" , "spring" , "autumn");
All of the above
What will be the output of the following program?
<?php
$a = 15;
function show() {
$a = 20; echo "$a";
}
show();
echo "$a";
?>
2020
2015
1515
0
How many Primary keys can have in a table?
Only 1
Only 2
Depends on no of Columns
Depends on DBA
If we have not specified ASC or DESC after a SQL ORDER BY clause, the following is used by default
DESC
ASC
There is no default value
None of the mentioned
Create a variable in php assign with the
String
const
let
$
Use the correct function to output the number of items in an array.
$fruits = array("Apple", "Banana", "Orange");
echo $fruits[0]
echo $fruits["Apple"]
echo count($fruits)
echo $fruits[0][1]
Write a correct syntax to include a file named "footer.php".
include ("footer.php");
import("footer.php");
required("footer.php");
export("footer.php");
Assume we have a file named "webdict.txt", write the correct syntax to open and read the file content.
readfile("webdict.txt")
openfile("webdict.txt")
writefile("webdict.txt")
modifyfile("webdict.txt")
Create a cookie named "username".
setcookie = ("username", "John", time() + (86400 * 30), "/");
setcookie("username", "John", time() + (86400 * 30), "/");
session("username", "John", time() + (86400 * 30), "/");
setsession("username", "John", time() + (86400 * 30), "/");
A period of time during which a particular person, views a number of web pages at a particular machine is called as a
session
cookie
parsing
In PHP, cookies are set by using the
setcookie() function
set() function
cookie_set() function
Name, value, expire, path, httponly, domain, secure all of these are arguments of
session()
cookie()
setcookie()
Which two predefined variables are used to retrieve information from forms?
$GET & $POST
$_GET & $_POST
&_GET & &_POST
A cookie is often used to identify a
USER
BROWSER
WEB PAGE
5. Which is a small file that the server embeds on the user's computer
SESSION
COOKIE
FILE
Session variables are set with the PHP global variable
$SESSION[]
$_SESSION[]
&SESSION
If the directive session.cookie_lifetime is set to 3600, the cookie will live until ____________
3600 sec
3600 mint
3600 hrs
In POST method the results at a given moment cannot be
SAVED
MOVE
BOOKMARKED
