ITEC106 - SHE

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/94

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:46 AM on 4/30/23
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

95 Terms

1
New cards
"PHP: Hypertext Preprocessor
PHP is an acronym for
2
New cards
PHP
* widely-used, open-source scripting language
* scripts are executed on the server
* free to download and use
3
New cards
text, HTML, CSS, JavaScript, and PHP code
PHP files can contain 5
4
New cards
server

HTML
PHP code is executed on the ____, and the result is returned to the browser as plain__ ___
5
New cards
.php
PHP files have extension
6
New cards
PHP can generate dynamic page content

PHP can create, open, read, write, delete, and close files on the server

PHP can collect form data

PHP can send and receive cookies

PHP can add, delete, modify data in your database

PHP can be used to control user-access

PHP can encrypt data
What can PHP Do?
7
New cards

1. runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
2. compatible with almost all servers used today (Apache, IIS, etc.)
3. supports a wide range of databases
4. is free. Download it from the official PHP resource: www.php.net
5. is easy to learn and runs efficiently on the server side
Why PHP?
8
New cards
HTML
A PHP scripting block always starts with __ __and ends with___.

A PHP scripting block can be placed anywhere in the document.

On servers with shorthand support enabled you can start a scripting block with .

For maximum compatibility, we recommend that you use the standard form (
A PHP file normally contains ____ tags, just like an HTML file, and some PHP scripting code.
9
New cards
echo
PHP has a built-in "_____" function, which is used to output text.

In actuality, it's **not a function; it's a language construct**.

As such, it **does not require parentheses.**
10
New cards
semicolon
Each code line in PHP must end with a ____. The__ ___ is a separator and is used to distinguish one set of instructions from another.
11
New cards
echo and print.
There are two basic statements to output text with PHP:
12
New cards
comment

\
In PHP code, a ____ is a line that is not executed as part of the program.

You can use _____ to communicate to others so they understand what you're doing, or as a reminder to yourself of what you did.
13
New cards
Multi-line

/\* \*/
_______ comments are used for composing comments that take more than a single line.

A _______ comment begins with ____ and ends with ____.
14
New cards
Variables

dollar sign ($)
___ __are used as "containers" in which we store information.__

__A PHP var_____able starts with a__ __*, which is followed by the name of the*__ _______.
15
New cards

1. A variable name must start with a letter or an underscore
2. A variable name cannot start with a number
3. A variable name can only contain alpha-numeric characters and underscores (A- z, 0-9, and _ )
4. Variable names are case-sensitive ($name and $NAME would be two different variables)
Rules for PHP variables:
16
New cards

1. String,
2. Integer,
3. Float,
4. Boolean,
5. Array,
6. Object,
7. NULL,
8. Resource.
8 Variables can store a variety of data types. Data types supported by PHP:
17
New cards
PHP String
– A __*is a sequence of characters, like "Hello world!".*__

__*A*__ *can be any text within a set of single or double quotes.*

*You can join two* ___ together using the dot ( .) concatenation operator.
18
New cards
PHP Integer –
An ____ is a whole number (without decimals) that must fit the following criteria:

It cannot contain commas or blanks;-

It must not have a decimal point;

and It can be either positive or negative.
19
New cards
PHP Float
– A _____, or__ ___-point number, is a number that includes a decimal point.
20
New cards
PHP Boolean
It represents two possible states: TRUE or FALSE.
21
New cards
Operators
_____ carry out operations on variables and values.
22
New cards
Arithmetic Operators
– work with numeric values to perform common arithmetical operations.
23
New cards
modulus operator
The _____ , represented by the % sign, returns the remainder of the division of the first operand by the second operand:
24
New cards

1. modulus operator
2. Addition
3. Subtraction
4. Multiplication
5. Division
5 Arithmetic Operators
25
New cards
Arithmetic Operators

Increment & Decrement Operator

Assignment Operators

Comparison Operators

Logical Operators
5 Operators
26
New cards
Increment & Decrement Operator
– The _______ are used to increment a variable's value. The _______ are used to decrement a variable's value.
27
New cards
post-increment returns the original value before it changes the variable,

pre-increment changes the variable first and then returns the value.

echo $x++; // post-increment echo "
";

echo $x--; // post-decrement echo "
";

echo ++$x; // pre-increment echo "
";

echo --$x; // pre-decrement echo "
";
Increment & Decrement Operator 2 TYPES
28
New cards
Assignment Operators
– used to write/assign values to variables.
29
New cards
Comparison Operators
– compare two values (numbers or strings).

are used inside conditional statements, and evaluate to either TRUE or FALSE.
30
New cards

1. Equal
2. Not equal
3. Greater than
4. Less than
5. Greater than or equal to
6. Less than or equal to
Comparison Operators 6 TYPES
31
New cards
Logical Operators
– are used to combine conditional statements.
32
New cards
and

or

xor

&&

||

!
Logical Operators 6 TYPES
33
New cards
Conditional statements
_____ perform different actions for different decisions.
34
New cards

1. if statement
2. if...else statement
3. if...elseif...else statement
4. switch statement
4 Conditional statements
35
New cards
if statement

Syntax: if (condition) { //code to be executed if condition is true; }
– executes some code if one condition is true
36
New cards
if...else statement

Syntax: if (condition) { //code to be executed if condition is true; } else{ //code to be executed if the condition is false; }
– executes some code if a condition is true and another code if that condition is false.
37
New cards
if...elseif...else statement

ex.


if ($age
– executes different codes for more than two conditions
38
New cards
switch statement

\

$favcolor = "red";

switch ($favcolor) {

case "red":

echo "Your favorite color is red!";

break;

case "blue":

echo "Your favorite color is blue!";

break;

case "green":

echo "Your favorite color is green!";

break;

default:

echo "Your favorite color is neither red, blue, nor green!"; }

//Output Your favorite color is red! ?>
–is an alternative to the if-elseif-else statement. Use the _____ statement to select one of a number of blocks of code to be executed.
39
New cards
default

break
The ____ statement is used if no match is found.

The ___ statement is used to break out of the switch when a case is matched.

If the ____ is absent, the code keeps running.
40
New cards
array
An _____ stores multiple values in one single variable.
41
New cards
Numeric or indexed arrays

Associative arrays

multidimensional arrays
In PHP, there are three kind of arrays:
42
New cards
Numeric or indexed arrays


$myArray\[0\] = "John";

$myArray\[1\] = " PHP ";

$myArray\[2\] = 21;

echo "$myArray\[0\] is $myArray\[2\] and knows $myArray\[1\]";

?> //Output: John is 21 and knows PHP
______ associate a numeric index with their values. The index can be assigned automatically (index always starts at 0), like this:
43
New cards
Associative arrays

\

$people = array("David"=>"27", "Amy"=>"21", "John"=>"42");

// or

$people\['David'\] = "27";

$people\['Amy'\] = "21";

$people\['John'\] = "42"; ?>

\
_____ are arrays that use named keys that you assign to them.
44
New cards
multi-dimensional array

\
2 dimentional array


$people = array( 'online'=>array('David', 'Amy’),

'offline'=>array('John', 'Rob', 'Jack’),

'away'=>array('Arthur', 'Daniel'));

echo $people\['online'\]\[0\] . ' ' . $people\['away'\]\[1\];

?>

//Output

David Daniel
A ___________ contains one or more arrays.

The arrays in the______ can be both numeric and associative.

The dimension of an array indicates the number of indices you would need to select an element.

For a ______array, you need two indices to select an element

For a _______ array, you need three indices to select an element
45
New cards
loops
Often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal lines in a script we can use _______ to perform a task like this.
46
New cards
while loop

do...while loop

for loop

foreach loop
4 looping statements:
47
New cards
while loop

Syntax:


$i = 1;

while ($i
The_____ executes a block of code as long as the specified condition is true.
48
New cards
do...while loop


$i=5;

do {

echo "The number is ". $i . "
";

$i++;

} while ($i
The ______ will always execute the block of code once, check the condition, and repeat the loop as long as the specified condition is true.
49
New cards
for loop

\

for ($a=0;$a
The ___ is used when you know in advance how many times the script should run.
50
New cards
init:

condition:

increment/decrement:
THE FOR LOOP 3 Parameters:

\
____Initialize the loop counter value

____Evaluates each time the loop is iterated, continuing if evaluates to true, and ending if it evaluates to false

____ Increases the loop counter value
51
New cards
foreach loop

\

$names = array("John", "David","Amy"); foreach($names as $name){

echo $name. "
"; }

?> /\* Output: John David Amy \*/
The _____ works only on arrays, and is used to loop through each key/value pair in an array.
52
New cards
continue statement
When used within a looping structure, the ______ allows for skipping over what remains of the current loop iteration. It then continues the execution at the condition evaluation and moves on to the beginning of the next iteration.
53
New cards
include and require statements
The ___ __&__ _____allow for the insertion of the content of one PHP file into another PHP file, before the server executes it.
54
New cards
require statement

include statement
The _____ is identical to include, the exception being that, **upon failure, it produces a fatal error.**

When a file is included using the______, but PHP is **unable to find it, the script continues to execute.**

In the case of require, the script will cease execution and produce an error.
55
New cards
require

include
Use ____ when the file is required for the application to run.

Use ____ when the file is not required. The application should continue, even when the file is not found.
56
New cards
function

\

function functionName() { //code to be executed } ?>
A _____ is a block of statements that can be used repeatedly in a program.

A _____ will not execute immediately when a page load. It will be executed by a call to the _____.
57
New cards
arguments
Information can be passed to functions through ______, which are like variables.

______ are specified after the function name, and within the parentheses.

You can add as many _____ as you want, as long as they are separated with commas.
58
New cards
parameters

argument
When you define a function, the variables that represent the values that will be passed to it for processing are called _______.

However, when you use a function, the value you pass to it is called an ____.
59
New cards
return statement
A function can return a value using the______. the______ stops the function's execution, and sends the value back to the calling code.
60
New cards
superglobal


1. $_SERVER,
2. $GLOBALS,
3. $_REQUEST,
4. $_POST,
5. $_GET,
6. $_FILES,
7. $_ENV,
8. $_COOKIE,
9. $_SESSION.
A ______ is a predefined variable that is always accessible, regardless of scope.

You can access the PHP _______ through any function, class, or file.

PHP's 9 _______ variables are
61
New cards
$_SERVER
is an array that includes information such as headers, paths, and script locations. The entries in this array are created by the web server.
62
New cards

1. \[‘PHP_SELF‘\]
2. \[‘SERVER_ADDR‘\]
3. \[‘SERVER_NAME‘\]
4. \[‘SERVER_PORT‘\]
5. \[‘HTTP_HOST‘\]
6. \[‘REMOTE_ADDR‘\]
7. \[‘REMOTE_HOST‘\]
8. \[‘REMOTE_PORT‘\]
9. \[‘SCRIPT_FILENAME‘\]
10. \[‘SCRIPT_NAME‘\]
11. \[‘SCRIPT_URI‘\]
$_SERVER 11 main elements
63
New cards
\[‘PHP_SELF‘\]
returns filename of the current executing script
64
New cards
\[‘SERVER_ADDR‘\]
returns ip add of the host server
65
New cards
\[‘SERVER_NAME‘\]
returns the name of the host server
66
New cards
\[‘HTTP_HOST‘\]
returns the Host header from the current request
67
New cards
\[‘REMOTE_ADDR‘\]
returns the ip add where the user is viewing the current page
68
New cards
\[‘REMOTE_HOST‘\]
returns the host name where the user is viewing the current page
69
New cards
\[‘REMOTE_PORT‘\]
returns the port being used on the user’s machine to communicate w/ the web server
70
New cards
\[‘SCRIPT_FILENAME‘\]
returns the absolute path name of the currently executing script
71
New cards
\[‘SERVER_PORT‘\]
returns the port on the server machine being used by the web server for communication (such as 80)
72
New cards
\[‘SCRIPT_NAME‘\]
returns the path of the current script
73
New cards
\[‘SCRIPT_URI‘\]
returns the URI of the current page
74
New cards
$_GET

$_POST
The purpose of the PHP superglobals __ __and__ ____ is to collect data that has been entered into a form.
75
New cards
PHP scripts
The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your______
76
New cards
action
The ______ attribute specifies that when the form is submitted, the data is sent to a PHP file named first.php.
77
New cards
$_POST

mwthod = “post'“
The built-in ___ __function is used to collect values from a form sent with__ ____.

Information sent from a form with the ___ __method is invisible to others and has no limits on the amount of information to send.__

___ is the preferred method for sending form data.

when we have an HTML form with the action attribute set to our PHP file, we can access the posted form data using the _____ associative array.

The _____ superglobal array holds key/value pairs.

In the pairs, keys are the names of the form controls and values are the input data entered by the user.
78
New cards
$_GET

mwthod = “get'“
The built-in____ function is used to collect values from a form sent within____.

Information sent from a form with the in____ method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send.
79
New cards
fopen()
The ___ __function creates or opens a file. If you use__ __ with a file that does not exist, the file will be created, given that the file has been opened for writing (w) or appending (a).
80
New cards

1. r
2. w
3. a
4. x
5. r+
6. w+
7. a+
8. x+
Manipulating Files 8 command :
81
New cards
r
Opens file for read only.
82
New cards
w
Opens file for write only. Erases the contents of the file or creates a new file if it doesn't exist.
83
New cards
a
Opens file for write only.
84
New cards
x
Creates new file for write only.
85
New cards
r+
Opens file for read/write.
86
New cards
w+
Opens file for read/write. Erases the contents of the file or creates a new file if it doesn't exist.
87
New cards
a+
Opens file for read/write. Creates a new file if the file doesn't exist
88
New cards
x+
Creates new file for read/write.
89
New cards
fwrite()

string
When writing to a file, use the___ __function.__

__The first parameter of__ __*is the file to write to; the second parameter is the*__ _____ to be written.
90
New cards
fclose()

\\n
The______ function closes an open file and returns TRUE on success or FALSE on failure. It's a good practice to close all files after you have finished working with them.

__The__ _ symbol is used when writing new lines.
91
New cards
a
When appending to a file using the ___ mode, the file pointer is placed at the end of the file, ensuring that all new data is added at the end of the file.
92
New cards
isset()
The ____ function determined whether the form had been submitted, as well as whether the text contained a value. We did not specify an action attribute for the form, so it will submit to itself.
93
New cards
file()
The ____function reads the entire file into an array. Each element within the array corresponds to a line in the file:
94
New cards
95
New cards

Explore top notes

note
Invisible Man Chapter 1
Updated 1173d ago
0.0(0)
note
Media & Information Literacy
Updated 322d ago
0.0(0)
note
Invisible Man Chapter 7
Updated 1173d ago
0.0(0)
note
Unit 3 : Macromolecules
Updated 313d ago
0.0(0)
note
International Cooperation
Updated 1195d ago
0.0(0)
note
Biochimie
Updated 746d ago
0.0(0)
note
Invisible Man Chapter 1
Updated 1173d ago
0.0(0)
note
Media & Information Literacy
Updated 322d ago
0.0(0)
note
Invisible Man Chapter 7
Updated 1173d ago
0.0(0)
note
Unit 3 : Macromolecules
Updated 313d ago
0.0(0)
note
International Cooperation
Updated 1195d ago
0.0(0)
note
Biochimie
Updated 746d ago
0.0(0)

Explore top flashcards

flashcards
S.S. Unit 3 - Study Guide
57
Updated 126d ago
0.0(0)
flashcards
Chapter 27
120
Updated 705d ago
0.0(0)
flashcards
Lit Words: 2 The Boogaloo
24
Updated 496d ago
0.0(0)
flashcards
Lab Practical 3
75
Updated 755d ago
0.0(0)
flashcards
Polyatomic Ions
21
Updated 768d ago
0.0(0)
flashcards
Latin Week 5
26
Updated 920d ago
0.0(0)
flashcards
Connect 4, Unit 3
52
Updated 1011d ago
0.0(0)
flashcards
S.S. Unit 3 - Study Guide
57
Updated 126d ago
0.0(0)
flashcards
Chapter 27
120
Updated 705d ago
0.0(0)
flashcards
Lit Words: 2 The Boogaloo
24
Updated 496d ago
0.0(0)
flashcards
Lab Practical 3
75
Updated 755d ago
0.0(0)
flashcards
Polyatomic Ions
21
Updated 768d ago
0.0(0)
flashcards
Latin Week 5
26
Updated 920d ago
0.0(0)
flashcards
Connect 4, Unit 3
52
Updated 1011d ago
0.0(0)