PHP Flashcards

1
Q

What does fmod() do?

A

Floating Modulus returns the modulus of a floating point number. number1 % number2.

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

What is the syntax for floating point modulus?

A

fmod($x, $y)

- x will be divided by y

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

What does XOR do?

A

Evaluates to true if one and only one condition is true.

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

What is || and how else can it be written?

A

It checks if at least 1 condition is true and if so returns true it can also be written as OR

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

What does && and how else can it be written?

A

Checks if both conditions are true and if so evaluates to true if one condition is false than then it evaluates to false. it can also be written as AND

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

What is a ternary operator?

A

A short hand for writing if constructs.

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

What is the syntax of a ternary operator?

A

$x = (CONDITION) ? TRUEBLOCK : FLASEBLOCK

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

What is a constant?

A

Constants are basically variable that can’t be redefined.

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

What is the syntax for creating a constant?

A

define(‘CONSTANT_NAME’, ‘CONSTANT_VALUE);

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

What is the php syntax for an array?

A

$x = array(item1, item2, item3,);

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

What is the shorthand syntax for an array and when can it be used?

A

$x = [item1, item2, item3,]; and it can be used as of php 5.4.

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

What is a statement?

A

A statement is the the shortest piece of code that communicates a complete thought.

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

When is the semicolon used?

A

At the end of a statement. It acts like a period.

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

what does strlen( ) do?

A

It will give you the length of the string that is passed to the function.

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

what does substr( ) do?

A

Selects a piece of a string. It is first passed a string, then a start point and the number of characters to return. i.e. substr(“Hello” 0, 3);
Would print “Hel”

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

what does strtoupper( ) do?

A

Converts the string it is passed to upper case.

17
Q

What does strtolower( ) do?

A

Converts the string it is passed to lower case.

18
Q

What does strpos( ) do?

A

It checks if a substring is in a string and gives it’s index/position.

19
Q

What does round( ) do and what are it’s parameter.

A

round( ) is used to round a floating numer up or down.
It’s first parameter is the number or number stored in a variable that is to be rounded and the second is the decimal place of where to round to.

20
Q

What does ceil( ) do?

A

Forces a floating point number to round up.

21
Q

What does floor( ) do?

A

Forces a floating point number to round down.

22
Q

what does rand( ) do?

A

Produces a random number between the two parameters set. i.e. rand(1,5);
would return a random number between 1 and 5.

23
Q

what does array_push( ) do?

A

Adds an item to an array. The first parameter is the array to add to and the second is what to add.

24
Q

what does count( ) do?

A

Returns the number of items in an array.

25
Q

What does join( ) do?

A

It joins the items of an array together it has to parameter the “glue” and the “array”. The glue is what you want to have between the array elements and the array is the array you want to perform the function on.
i.e. join(“test “, $theArray);
would return all the elements in side the $theArray array and join them together with test (and then a space).

26
Q

what does sort( ) do?

A

It sorts the elements in an array from lowest to highest or A - Z.

27
Q

What does rsort( ) do?

A

It sorts the elements in an array from highest to lowest or from Z - A.