• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/32

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

32 Cards in this Set

  • Front
  • Back

CONCATENATE

. for most things


.= to add to variables

Create array

$arrayName=array('item1', 'item2');

view whole array

print_r($arrayName);

view specific of array

echo $arrayName[1];

Add to array

$arrayName[]= 'item3';

length of array

count($arrayName);

Output array

echo 'this is an array' . $arrayName[1];




If associative


echo "this is an {$arrayName[red]}"

Associative Array Creation

$assArray= array('red'=> 'apple', 'yellow' =>


'banana')

Add to associative array

$assArray['key']='new item';

Comparitors

&& = and


|| = or

Switch statements

switch($variabletocompare){


case 'valueofvariable':


result;


break;


case 'option1:


case 'option2':


result;


break;


default:


result;


}

Shorthand if

$result= (argument) ? true : false;

While loop

$i=1




while ($i<10){


result;


$i++;


}

Do While

do {


result;


$i++;


}while ($i<10);

For Loop

for ($i=0; argument; $i++){


result;


}

Skipping part of For loop

to skip one part of for loop then use if statement with continue as result

For Each




Used with?


Syntax

Arrays


foreach($arrayName as $value){


result;


}




note: $value is just a throw away temp variable and does not matter the name

For each Associative Array

foreach ($arrayName as $key => $value){


result;


}


note: $key and $value is just a throw away temp variable and does not matter the name

Function (pass by value)

function functionname($variable){


code to do;


return $result;


}

To use function

functionname($variable or amount);

Function (pass by reference)

function nameoffunction(&$existingvariable){


code;


result;


}

Includes file path

needs to be relative and have ./ in front of it




EX: ./folder/newfile.php

Objects and Methods




How to initialize object


How to call method

$variable= new object;


$objectvariable -> $method('method parameters');

How to make a class

class classname{


code; //can include functions


}

Superglobals

Always start with underscore and are in all caps

Form Variable Names

name="thisisvariablename"

Mail Function

mail($to, $subject, $body); //$headers are optional

Adding headers to mail

$header can add cc, bcc, from


Must end in new line \r\n


may need -fmyemail@address.com at end of header


add to header by using concatenate

MySQL validation

mysql_real_escape_string($var);

how to check if form field is filled in?

isset($_POST('name');

text validation

$excludeString= '/everything to exclude/';


preg_match($excludeString,$vartotest);




pregmatch gives either 0 or 1

test length of string

strlen($string)