Intro to PHP 2 Flashcards

1
Q

Name two types of numeric variables

A

floating point and integer

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

How do you create an array>

A

$arraymine = array(‘Mii’);

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

PHP is a loosely typed language; what does this mean for variables?

A

variables do not have to be declared before they
are used

PHP always converts variables to the type required
by their context when they are accessed.

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

What are the key elements of strongly typed languages?

A

Static type checking
• Generate an error or refuse to compile
• No possibility of an unchecked runtime type error

In favor of type safety
– Smalltalk, Perl, JavaScript, Ruby, Python,

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

Describe a weakly typed language

A

Dynamic type-checking
Implicit type conversions
E.g. both C++ and C# allow programs to define operators to
convert a value from one type to another in a meaningful
way.

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

What are magic constants?

A

There are dozens already available without being defined, some of these are magic constants. They are:

_LINE_
_FILE_
_DIR_
_FUNCTION_
_CLASS_
_METHOD_
_NAMESPACE_
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between echo and print?

A

print is a function that takes in a variable (returns something)

echo is a php language construct(does not return anything)

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

What is the difference between a local and global variable?

A

Local variables cannot be used outside without a function. they are not to be used for long term variables, but usuall just to be used within a function.

Global variables need to use the keyword global

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

What is a superglobal?

A

They are predefined by the php environment and are accessible from anywhere

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

Name three super globals

A
$GLOBALS
$_GET
$_POST
$_FILES
$_SESSION
$_REQUEST
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How would you avoid attackers using superglobals against you?

A

Sanitize them with the htmlentities PHP function

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

What is the difference between include and require?

A

Include will attempt to use the file. Require will attempt to use the file, and if it cannot be used, it will not continue with the program. It will stop

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