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
Q

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.

A

comment; read by someone

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

Comments can be used to:
* Let others…

A

understand what you are doing

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

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

A

Remind yourself of what you did

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

php code snippet with comments example

A

Example

<html>
<body>

</body>
</html>

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

Example

<html>
<body>

</body>
</html>

does all those echos work?

A

yes

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

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

<html>
<body>

</body>
</html>

A

when it comes to variables, php is case-sensitive

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

Data Types: Variables can store data of different types, and different data types can do different things. PHP supports the following data types: (8)

A
  • String
  • Integer
  • Float (floating point numbers - also called double)
  • Boolean
  • Array
  • Object
  • NULL
  • Resource
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

A ___ is a sequence of characters, like “Hello world!”.

A

string

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

A ___ can be any text inside quotes. You can use single or double quotes:

A

string

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

String Functions
* Get The Length of a String
* The ___ function returns the length of a string.

A

PHP strlen()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q
  • The example below returns the length of the string “Hello world!”

Example

<html>
<body>

</body>
</html>

A

OUPUT:
12

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

Count The Number of Words in a String
The ___ function counts the number of words in a string:
Example

<html>
<body>

</body>
</html>

A

PHP str_word_count();
OUPUT:
2

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

Reverse a String
* The ___ function reverses a string:
Example

<html>
<body>

</body>
</html>

A

PHP strrev(); OUTPUT:
!dlrow olleH

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

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

<html>
<body>

</body>
</html>

A

PHP strpos();
returns the character position;
FALSE;
OUPUT:
6

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

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

<html>
<body>

</body>
</html>

A

PHP str_replace();
OUPUT:
Hello Dolly!

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

PHP Integer: An ___ is a non-decimal number between -2,147,483,648 and 2,147,483,647.

A

integer data type

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

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

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
Q
  • In the following example $x is an integer. The ___ function returns the data type and value:
    Example

<html>
<body>

</body>
</html>

A

PHP var_dump();
OUTPUT:
int(5985)

43
Q

A ___ (floating point number) is a number with a decimal point or a number in exponential form.

A

float

44
Q

In the following example $x is a float. The ___ function returns the data type and value:
Example

<html>
<body>

</body>
</html>

A

PHP var_dump() ;
OUTPUT:
float(10.365)

45
Q

A ___ represents two possible states: TRUE or FALSE.
$x = true;
$y = false;

A

Boolean

46
Q

___ are often used in conditional testing.

A

Booleans

47
Q

An ___ stores multiple values in one single variable

A

array

48
Q

An ___ is a special variable, which can hold more than one value at a time.

A

array

49
Q

An ___ can hold many values under a single name, and you can access the
values by referring to an ___.

A

array; index number

50
Q

Array Example

A

<html>
<body>

</body>
</html>

51
Q

Create an Array in PHP
* In PHP, the ___ function is used to create an array

A

array();

52
Q

In PHP, there are three types of arrays:

A
  • Indexed arrays
  • Associative arrays
  • Multidimensional arrays
53
Q

Arrays with a numeric index

A

Indexed arrays

54
Q

Arrays with named keys

A

Associative arrays

55
Q

Arrays containing one or more arrays

A

Multidimensional arrays

56
Q

___ are “containers” for storing information.

A

Variables

57
Q

Creating (Declaring) PHP Variables: In PHP, a variable starts with the ___ sign, followed by the ___

A

$ ; name of the variable

58
Q

Example of variable declaration

<html>
<body>

</body>
</html>

A

Output:
Hello world!
5
10.5

59
Q

Note: When you assign a text value to a variable, put ___ around the value.

A

quotes

60
Q

Note: Unlike other programming languages, PHP has ___. It is created the moment you first assign a value to it.

A

no command for declaring a variable

61
Q

Rules for PHP variables:

A

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
Q

Output Variables
* The ___ is often used to output data to the screen

A

PHP echo statement

63
Q

In PHP, variables can be declared ___ in the script.

A

anywhere

64
Q

The ___ is the part of the script where the variable can be referenced/used.

A

scope of a variable

65
Q

PHP has three different variable scopes:

A
  • local
  • global
  • static
66
Q

A variable declared outside a function has a ___ and can only be accessed outside a function:

A

GLOBAL SCOPE

67
Q

A variable declared within a function has a ___ and can only be accessed within that function:

A

LOCAL SCOPE

68
Q

The ___ is used to access a global variable from within a function.

A

global keyword

69
Q

To create a global variable, use the keyword: ___ before the variables (inside the function):

A

“global”

70
Q

Normally, when a function is completed/executed, all of its variables are ___.

A

deleted

71
Q

Sometimes we want a local variable NOT to be deleted.

A

To do this, use the keyword: “static “ when you first declare the variable:

72
Q

In PHP there are two basic ways to get output:

A

echo and print.

73
Q

echo and print are more or less the same. They are both used to ___ to
the screen.

A

output data

74
Q

___ has no return value while ___ has a return value of 1 so it can be used in expressions.

A

echo; print

75
Q

___ can take multiple parameters (although such usage is rare) while ___ can take one argument.

A

echo; print

76
Q

which is marginally faster between echo and print?

A

echo

77
Q

The echo statement can be used ___ parentheses:

A

with or without; echo or echo()

78
Q

The print statement can be used ___ parentheses:

A

with or without; print or print()

79
Q

An ___ is a data type which stores data and information on how to process that data.

A

object

80
Q
  • 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:
A

explicitly declared;
class of object;
class keyword;
class

81
Q

___ is a special data type which can have only one value: NULL.

A

Null

82
Q

A variable of data type ___ is a variable that has no value assigned to it.

A

NULL

83
Q

If a variable is created without a value, it is automatically assigned a value of ___.

A

NULL

84
Q

Variables can also be emptied by setting the value to ___:

A

NULL

85
Q

___ are like variables except that once they are defined they cannot be changed or undefined.

A

Constants

86
Q

A ___ is an identifier (name) for a simple value. The value cannot be changed during the script.

A

constant

87
Q

A ___ starts with a letter or underscore (no $ sign before the constant name).

A

valid constant name

88
Q

Unlike variables, constants are ___ across the entire script.

A

automatically global

89
Q

To create a constant, use the ___ function.

A

define()

90
Q

define(name, value, case-insensitive)

A

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
Q

False or True: Constants are Global

A

True

92
Q

___ are automatically global and can be used across the entire script.

A

Constants

93
Q

___ are used to perform operations on variables and values.

A

Operators

94
Q

PHP divides the operators in the following groups:

A
  • Arithmetic operators
  • Assignment operators
  • Comparison operators
  • Increment/Decrement operators
  • Logical operators
  • String operators
  • Array operators
95
Q

The ___ are used with numeric values to perform common arithmetical operations, such as addition, subtraction, multiplication etc.

A

PHP arithmetic operators

96
Q

The ___ are used with numeric values to write a value to a variable.

A

PHP assignment operators

97
Q

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

A

”=”

98
Q

The ___ are used to combine conditional statements.

A

PHP logical operators

99
Q

PHP has two operators that are specially designed for strings

A

concatenation and concatenations assignment

100
Q

The ___ are used to compare arrays.

A

PHP array operators