WorksheetsWebApp (Webdev2)
Total questions: 108
Worksheet time: 2hrs 4mins
it is a popular open-source scripting language.
(a)
PHP was created in 1994 by ________, and around the 2000s it became very famous because of its simplicity.
Rasmus Lerdorf
Randolf Espejo
Anders Hejlsberg
James Gosling
When was PHP created?
1994
1984
1974
2004
What's the name of popular social media, that uses PHP as it’s one of the back-end languages. And it was originally coded on PHP
viber
A PHP file can contain HTML + PHP code combined. It can practically be just an HTML document.
True
False
To output something in PHP, we can use either (a) or print.
___________are faster to be translated but it doesn’t really matter nowadays. It does not do string interpolation.
Single quotes
Double quotes
Code use to have Line Breaks.
<br/>
<nl2br/>
<p>
<snr/>
Variables should start with ____ - This is the legacy of Perl.
?
&
$
#
Variables have no types.
True
False
Arrays cannot be mixed in PHP.
True
False
What function can we use in inspecting an Array?
var_dump
fopen()
fread()
abs()
What kind of Arrays is this?
$cars = array(‘honda’ => 50500, ‘toyota’=>40700, ‘mazda’ =>60300)
Associative Arrays
Multidimensional Arrays
What kind of Arrays is this?
$cars = array(“expensive” => array(), “inexpensive” =>array())
echo $cars[“inexpensive”][2]
Associative Arrays
Multidimensional Arrays
Which of the following is an Arithmetic Operator?
%
+=
===
<==>
Which of the following is an Assignment Operator?
-
-=
>
<==>
Which of the following is a Comparison Operator?
+=
<==>
===
%
Which of the following is a Spaceship Operator?
/
*=
<=
<==>
Which of the following is a Logical Operator?
<==>
||
==
%=
It allows us to re-order the applications of XOR so that the duplicated elements are next to each other. Since x ^ x = 0 and a ^ 0 = a, each pair of duplicated values has no effect on the outcome.
Formatting
Associative
Commutativity
Temp
Which of the following is a Pre-Increment Operator?
$x--
--$x
$x++
++$x
Which of the following is a Post-Increment Operator?
$x--
$x++
++$x
--$x
Which of the following is a Pre-Decrement Operator?
++$x
$x++
$x--
--$x
Which of the following is a Post-Decrement Operator?
++$x
$x++
--$x
$x--
Incrementing null results in __?
1
- 1
0
2
Incrementing an empty string results in __ ?
- 1
1
0
+ 1
Incrementing a string will result in the last character shifted to __ ?
1
0
- 1
+1
Classic alternative to the if-elseif condition:
Switch statement
While Loop
Do-while Loop
For Loop
What do you call this format?
if-else if condition
if-else condition
if condition
Switch Statement
What do you call this format?
if condition
if-else condition
if-else if condition
Switch Statement
What do you call this kind of Looping?
While Loop
Do-while Loop
For Loop
foreach loop
What do you call this kind of Looping?
While Loop
Do-while Loop
For Loop
Foreach Loop
What do you call this kind of Looping?
While Loop
Do-While Loop
For Loop
Foreach Loop
What do you call this kind of Looping?
While Loop
Do-While Loop
For Loop
Foreach Loop
is a block of code written in a program to perform some specific task.
Scope
Function
Argument
Parameter
Two major types of function:
Built-in function
User-defined function
Temp
Chore Function
Why use functions?
Reusability
Easy for error detection
Maintenance
Fancy Code
What are the three major coding standards when creating functions? (and variables for that matter)
Camel Case
Lowercase and underscores
Pascal case
Uppercase and underscores
It is the variable used to hold the value.
Parameters
Arguments
Function
Constant
It is the value passed to the function.
Parameters
Arguments
Function
Constant
The original value passed to the function gets copied. Any changes to the value do not affect the original value. (This is the default behavior.)
Pass by Value
Pass By Reference
The argument becomes an alias to the original argument. Any changes to the value get reflected on the original variable.
Pass by Value
Pass by Reference
This is an example of Passing by _____?
Value
Reference
Variable as subject to scope.
True
False
A scope is indicated by the ___ block.
{ }
[ ]
( )
< >
Variables are declared inside a {} is what we called?
Local
Global
International
Inter-global
It is a name or an identifier for a fixed value.
Constants
Arguments
Parameters
Function
What are the two ways to create - define or const?
define(“IDENTIFIER_NAME”, value);
const MY_COURSE = “BSIS2”;
define(“IDENTIFIER_NAME”, echo);
const MY_COURSE = printF;
What do you call this kind of syntax?
include ‘/path/file.php’
Including Documents
Excluding Documents
Requiring Documents
Referring Documents
What do you call this kind of syntax?
require ‘/path/file.php’
Include
Required
Exclude
Referred
(Include vs Require)
It will just print a warning if the file is not found
Required
Include
(Include vs Require)
It will throw an error if the file is not found.
Require
Include
Built-in function for Length:
ucwords($str)
strpos($email, “@”);
strlen($str)
str_word_count($str)
Built-in function for Word Count:
ucwords($str)
trlen($str)
str_word_count($str)
strpos($email, “@”);
Built-in function for Finding Text within a string:
strlen($str)
str_word_count($str)
strpos($email, “@”);
ucwords($str)
Built-in function for Capitalize first letter:
strlen($str)
str_word_count($str)
strpos($email, “@”);
ucwords($str)
Built-in function for Uppercase everything:
ucwords($str)
str_word_count($str)
strtoupper($str)
strtolower($str)
Built-in function for Lowercase everything:
strlen($str)
str_word_count($str)
strtoupper($str)
strtolower($str)
Built-in function for Removing leading and trailing space:
ucwords($str)
trim($str)
strlen($str)
strtolower($str)
What is this built-in function for?
ceil (0.5)
Rounds up to the nearest integer
Rounds down to the nearest integer
Round according to math logic
Exponentiation
What is this built-in function for?
floor(0.50)
Rounds up to the nearest integer
Rounds down to the nearest integer
Round according to math logic
Exponentiation
What is this built-in function for?
round(0.54335, 2)
Rounds up to the nearest integer
Rounds down to the nearest integer
Round according to math logic
Exponentiation
What is this built-in function for?
exp($num)
Rounds up to the nearest integer
Rounds down to the nearest integer
Round according to math logic
Exponentiation
What is this syntax for?
A. $arr1 = array(“firstname”=>”jasper”)
B. $arr2 = array(“lastname”=>”rebong)
C. $all = array_merge($arr1, $arr2)
Merging arrays
Get only the keys of an associative array
Get only the values
Insert element to the last index
What is this built-in function for?
array_keys($arr)
Get only the keys of an associative array
Get only the values
Insert element to the last index
Searching inside an array
What is this built-in function for?
array_values($arr)
Get only the keys of an associative array
Get only the values
Insert element to the last index
Searching inside an array
What is this built-in function for?
array_push($arr, $value)
Count the number of items in an array
Search for a value inside an array
Insert element to the last index
Searching inside an array
What is this built-in function for?
array_search(“key”, $array)
(it returns the index)
We can get the minimum and maximum
Count the number of items in an array
Search for a value inside an array
Searching inside an array
What is this built-in function for?
in_array(key, array)
(it returns a boolean value)
Get the last value of the array
Searching inside an array
Search for a value inside an array
Count the number of items in an array
What is this built-in function for?
count($array)
Get only the values
Get only the keys of an associative array
We can get the minimum and maximum
Count the number of items in an array
Built-in function that can get the minimum and maximum value of an Array.
min() and max()
sml() and big()
sml() and lrg()
mine() and yrs()
Built-in function that can Get the last value of the array.
lastValue()
last()
end()
endVal()
How to create this format?
March 31, 2022, 7:03 pm
$today = date("F j, Y, g:i a");
$today = date("m.d.y");
$today = date("j, n, Y");
$today = date("Ymd");
How to create this format?
03.31.22
$today = date("F j, Y, g:i a");
$today = date("m.d.y");
$today = date("j, n, Y");
$today = date("Ymd");
How to create this format?
31, 3, 2022
$today = date("F j, Y, g:i a");
$today = date("m.d.y");
$today = date("j, n, Y");
$today = date("Ymd");
How to create this format?
20220331
$today = date("F j, Y, g:i a");
$today = date("Ymd");
$today = date("j, n, Y");
$today = date("m.d.y");
How to create this format?
12-27-18, 31-03-22, 1631 1618 6 Satpm01
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');
$today = date("D M j G:i:s T Y");
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');
$today = date('h-i-s, j-m-y, it is w Day');
How to create this format?
it is the 31th day.
$today = date("H:i:s");
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');
$today = date("D M j G:i:s T Y");
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');
How to create this format?
Sat Mar 10 17:16:18 MST 2001
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');
$today = date("Y-m-d H:i:s");
$today = date("D M j G:i:s T Y");
$today = date("F j, Y, g:i a");
How to create this format?
17:03:18 m is month
$today = date("Y-m-d H:i:s");
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');
$today = date("j, n, Y");
$today = date("H:i:s");
How to create this format?
12:32:18
$today = date("D M j G:i:s T Y");
$today = date("Y-m-d H:i:s");
$today = date("F j, Y, g:i a");
$today = date("H:i:s");
How to create this format?
2001-03-10 17:16:18 (the MySQL DATETIME format)
$today = date("D M j G:i:s T Y");
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');
$today = date("Y-m-d H:i:s");
$today = date("H:i:s");
Since a webpage is can be accessed anywhere in the world, the date-time values can be different for each user.
We can set the default timezone and force the system to be consistent.
just type this:
date_default_timezone_set(‘Europe/Amsterdam’)
to be familiarized.
The standard random number generator is ____ - it generates between 0 and MAXINT
rand()
math()
brand()
int()
The maximum number can be retrieved using ______?
getrandmax()
rand(1,10)
rand(max)
rand(randmax)
The syntax for passing arguments will enable us to generate a random number between 2 values.
rand(1,10)
math(randNum)
rand($int)
rand(max)
What is this for?
header(“location: location2.php”)
To forward a page to a new location
To test if a variable is declared but is not null
Get only the keys of an associative array
Insert element to the last index
What is this for?
isset()
To test if a variable is declared but is not null
To forward a page to a new location
To backward a page to a new location
To test if a argument is declared but is not null
__________are global variable that is provided by the system
They are available from any part of our code
Mainly used to store and get data from one page to another
Superglobals
Inter-global
global
Local
What method is used in these lines of code? (it means that the data will not be visible to others.)
Post
Get
Session
Cookie
What method is used in these lines of code? (It means that the data will not be visible to others or the data will be visible in the URL string. DO NOT USE THIS METHOD WHEN SUBMITTING A PASSWORD)
Post
Get
Session
Cooki
- Used to store data in the server.
- It is good to use for sensitive data
- It exists as long as the same browser is open. It ends when the browser is closed.
Session
Cookie
Get
Post
How to start a session?
session_start()
start(session)
_startsession()
start_session()
What is this code for?
to start a session
to store information - using the $_SESSION superglobal.
To stop a session
What is this code for?
session_destroy()
to start a session
to store information
To stop a session
Small file that the webserver stores in the client computer.
Cookie
Session
Post
Get
How to set the cookie data we use one function.
setcookie()
cookie()
cookieset()
set(cookie)
session_detroy use to stop Cookie.
False
True
What is this code use for?
To expire a cookie, that needs to pass a time value that is in the past.
To stop a cookie, that needs to pass a time value that is in the past
To create a cookie, that needs to pass a time value that is in the past
To deploy a cookie, that needs to pass a time value that is in the past
What is this code use for?
to upload files via PHP
to download files from PHP
to delete files via PHP
to update files via PHP
What is this code for?
echo $_FILES[‘file’][‘name’];
Show us the filename
Show us the file type (jpg, etc)
Show us the file path where it is saved
0 if there is error, 1 if there is error
What is this code for?
echo $_FILES[‘file’][‘type];
Show us the filename
Show us the file type (jpg, etc)
Show us the file path where it is saved
0 if there is error, 1 if there is error
What is this code for?
echo $_FILES[‘file’][‘tmp_name];
Show us the filename
Show us the file type (jpg, etc)
Show us the file path where it is saved
0 if there is error, 1 if there is error
What is this code for?
echo $_FILES[‘file’][‘error];
Show us the filename
Show us the file type (jpg, etc)
Show us the file path where it is saved
0 if there is error, 1 if there is error
What is this code use for?
Create and Write to a File
Update and Write to a File
Read and Write to a File
Delete and Write to a File
What is this code used for?
$fn = file_get_contents(“path/filename”);
echo $fn;
Read from File
Create and Write to a File
Delete from File
Update from File
What is this code used for?
to create a a form to append to a file
Read from File
Read from File line by line
File Details
The Form Processor
(wala lang pinakita ko lang, titigan mo ng 3 mins. tas magsulat ka ng kahit ano jan)
