Semis Lecture 1 Flashcards

1
Q

___ is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.

A

PHP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

PHP is a ___, and a powerful tool for making dynamic and interactive Web pages.

A

server scripting language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

PHP is a widely-used, free, and efficient alternative to competitors such as ___.

A

Microsoft’s ASP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

sample php code block

A

<html>
<body>
< ?php
echo "My first PHP
script!"; ? >"
</body>
</html>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

PHP is an acronym for…

A

“PHP: Hypertext Preprocessor”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

PHP is a widely-used, …

A

open source scripting language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

___ are executed on the server

A

PHP scripts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

PHP is free to ___

A

download and use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a PHP File? PHP files can contain… (5)

A

text, HTML, CSS, JavaScript, and PHP code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

___ are executed on the server, and the result is returned to the browser
as plain HTML

A

PHP code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

PHP files have extension…

A

“.php”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What Can PHP Do?
* PHP can generate ___
* PHP can ___ on the server
* PHP can collect ___
* PHP can ___ cookies
* PHP can ___ in your database
* PHP can be used to ___
* PHP can ___

A

dynamic page content;
create, open, read, write, delete, and close files;
form data;
send and receive;
add, delete, modify data;
control user-access;
encrypt data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

With PHP you are not limited to ___. You can output (a), (b), and even (c). You can also output any text, such as (d) and (e).

A

output HTML; (a) images, (b) PDF files, (c) Flash movies, (d) XHTML, (e) XML

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why PHP?
* PHP runs on ___ (Windows, Linux, Unix, Mac OS X, etc.)

A

various platforms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why PHP?
* PHP is compatible with ___ (Apache, IIS, etc.)

A

almost all servers used today

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Why PHP?
* PHP supports a ___

A

wide range of databases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Why PHP?
* PHP is ___. Download it from the official PHP resource: www.php.net

A

free

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Why PHP?
* PHP is ___ and ___ on the server side

A

easy to learn; runs efficiently

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

To start using PHP, you can:
* Find a ___ with PHP and MySQL support
* Install a ___ on your own PC, and then install PHP and MySQL

A

web host; web server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Use a Web Host with PHP Support
* If your server has activated support for PHP…
* Just create some ___, place them in your web directory, and the server will automatically parse them for you.
* You do not need to compile anything or install any extra tools.
* Because PHP is free, most ___ offer PHP support.
* Set Up PHP on Your Own PC

A

you do not need to do anything;
.php files;
web hosts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

However, if your server does not support PHP, you must:
* install a (a)
* install (b)
* install a (c), such as MySQL

A

(a) web server;
(b) PHP;
(c) database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Basic PHP Syntax
* A ___ can be placed anywhere in the document.
* A PHP script starts with ___ and ends with ___

A

PHP script; <?php & ?>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

sample of basic php syntax

A

<?php
// PHP code goes
here ?>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Example

<html>
<body>
<h1>My first PHP page</h1>

</body>
</html>

  • PHP statements end with a ___
A

semicolon (;)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
A ___ in PHP code is a line that is not read/executed as part of the program. Its only purpose is to be ___ who is looking at the code.
comment; read by someone
26
Comments can be used to: * Let others...
understand what you are doing
27
Comments can be used to: * Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments can remind you of what you were thinking when you wrote the code
Remind yourself of what you did
28
php code snippet with comments example
Example
29
Example "; echo "Hello World!
"; EcHo "Hello World!
"; ?> does all those echos work?
yes
30
In the example below, only the first statement will display the value of the $color variable (this is because $color, $COLOR, and $coLOR are treated as three different variables): Example "; echo "My house is " . $COLOR . "
"; echo "My boat is " . $coLOR . "
"; ?>
when it comes to variables, php is case-sensitive
31
Data Types: Variables can store data of different types, and different data types can do different things. PHP supports the following data types: (8)
* String * Integer * Float (floating point numbers - also called double) * Boolean * Array * Object * NULL * Resource
32
A ___ is a sequence of characters, like "Hello world!".
string
33
A ___ can be any text inside quotes. You can use single or double quotes:
string
34
String Functions * Get The Length of a String * The ___ function returns the length of a string.
PHP strlen()
35
* The example below returns the length of the string "Hello world!" Example
OUPUT: 12
36
Count The Number of Words in a String The ___ function counts the number of words in a string: Example
PHP str_word_count(); OUPUT: 2
37
Reverse a String * The ___ function reverses a string: Example
PHP strrev(); OUTPUT: !dlrow olleH
38
Search For a Specific Text Within a String * The ___ function searches for a specific text within a string. * If a match is found, the function ___ of the first match. If no match is found, it will return ___. * The example below searches for the text "world" in the string "Hello world!": Example
PHP strpos(); returns the character position; FALSE; OUPUT: 6
39
Replace Text Within a String * The ___ function replaces some characters with some other characters in a string. * The example below replaces the text "world" with "Dolly": Example
PHP str_replace(); OUPUT: Hello Dolly!
40
PHP Integer: An ___ is a non-decimal number between -2,147,483,648 and 2,147,483,647.
integer data type
41
Rules for integers: * An integer must have (a) * An integer must not have a (b) * An integer can be (c) * Integers can be specified in three formats: (d, 3)
a - at least one digit b - decimal point c - either positive or negative d - decimal (10-based), hexadecimal (16-based - prefixed with 0x) or octal (8-based - prefixed with 0)
42
* In the following example $x is an integer. The ___ function returns the data type and value: Example
PHP var_dump(); OUTPUT: int(5985)
43
A ___ (floating point number) is a number with a decimal point or a number in exponential form.
float
44
In the following example $x is a float. The ___ function returns the data type and value: Example
PHP var_dump() ; OUTPUT: float(10.365)
45
A ___ represents two possible states: TRUE or FALSE. $x = true; $y = false;
Boolean
46
___ are often used in conditional testing.
Booleans
47
An ___ stores multiple values in one single variable
array
48
An ___ is a special variable, which can hold more than one value at a time.
array
49
An ___ can hold many values under a single name, and you can access the values by referring to an ___.
array; index number
50
Array Example
51
Create an Array in PHP * In PHP, the ___ function is used to create an array
array();
52
In PHP, there are three types of arrays:
* Indexed arrays * Associative arrays * Multidimensional arrays
53
Arrays with a numeric index
Indexed arrays
54
Arrays with named keys
Associative arrays
55
Arrays containing one or more arrays
Multidimensional arrays
56
___ are "containers" for storing information.
Variables
57
Creating (Declaring) PHP Variables: In PHP, a variable starts with the ___ sign, followed by the ___
$ ; name of the variable
58
Example of variable declaration "; echo $x; echo "
"; echo $y; ?>
Output: Hello world! 5 10.5
59
Note: When you assign a text value to a variable, put ___ around the value.
quotes
60
Note: Unlike other programming languages, PHP has ___. It is created the moment you first assign a value to it.
no command for declaring a variable
61
Rules for PHP variables:
A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). * A variable starts with the $ sign, followed by the name of the variable * A variable name must start with a letter or the underscore character * A variable name cannot start with a number * A variable name can only contain alpha-numeric characters and underscores (Az, 0-9, and _ ) * Variable names are case-sensitive ($age and $AGE are two different variables)
62
Output Variables * The ___ is often used to output data to the screen
PHP echo statement
63
In PHP, variables can be declared ___ in the script.
anywhere
64
The ___ is the part of the script where the variable can be referenced/used.
scope of a variable
65
PHP has three different variable scopes:
* local * global * static
66
A variable declared outside a function has a ___ and can only be accessed outside a function:
GLOBAL SCOPE
67
A variable declared within a function has a ___ and can only be accessed within that function:
LOCAL SCOPE
68
The ___ is used to access a global variable from within a function.
global keyword
69
To create a global variable, use the keyword: ___ before the variables (inside the function):
"global"
70
Normally, when a function is completed/executed, all of its variables are ___.
deleted
71
Sometimes we want a local variable NOT to be deleted.
To do this, use the keyword: "static " when you first declare the variable:
72
In PHP there are two basic ways to get output:
echo and print.
73
echo and print are more or less the same. They are both used to ___ to the screen.
output data
74
___ has no return value while ___ has a return value of 1 so it can be used in expressions.
echo; print
75
___ can take multiple parameters (although such usage is rare) while ___ can take one argument.
echo; print
76
which is marginally faster between echo and print?
echo
77
The echo statement can be used ___ parentheses:
with or without; echo or echo()
78
The print statement can be used ___ parentheses:
with or without; print or print()
79
An ___ is a data type which stores data and information on how to process that data.
object
80
* In PHP, an object must be ___. * First we must declare a ___. For this, we use the ___. A ___ is a structure that can contain properties and methods:
explicitly declared; class of object; class keyword; class
81
___ is a special data type which can have only one value: NULL.
Null
82
A variable of data type ___ is a variable that has no value assigned to it.
NULL
83
If a variable is created without a value, it is automatically assigned a value of ___.
NULL
84
Variables can also be emptied by setting the value to ___:
NULL
85
___ are like variables except that once they are defined they cannot be changed or undefined.
Constants
86
A ___ is an identifier (name) for a simple value. The value cannot be changed during the script.
constant
87
A ___ starts with a letter or underscore (no $ sign before the constant name).
valid constant name
88
Unlike variables, constants are ___ across the entire script.
automatically global
89
To create a constant, use the ___ function.
define()
90
define(name, value, case-insensitive)
Parameters: * name: Specifies the name of the constant * value: Specifies the value of the constant * case-insensitive: Specifies whether the constant name should be case-insensitive. Default is false
91
False or True: Constants are Global
True
92
___ are automatically global and can be used across the entire script.
Constants
93
___ are used to perform operations on variables and values.
Operators
94
PHP divides the operators in the following groups:
* Arithmetic operators * Assignment operators * Comparison operators * Increment/Decrement operators * Logical operators * String operators * Array operators
95
The ___ are used with numeric values to perform common arithmetical operations, such as addition, subtraction, multiplication etc.
PHP arithmetic operators
96
The ___ are used with numeric values to write a value to a variable.
PHP assignment operators
97
The basic assignment operator in PHP is ___. It means that the left operand gets set to the value of the assignment expression on the right
"="
98
The ___ are used to combine conditional statements.
PHP logical operators
99
PHP has two operators that are specially designed for strings
concatenation and concatenations assignment
100
The ___ are used to compare arrays.
PHP array operators