number of first character in string or first item of an array in PHP
Front
0
Back
PHP substr();
Front
-gets passed a string or var containing a string
-allows you to return a substring of another string
substr($var, number to start at, how many to go forward with);
Back
PHP foreach loops purpose
Front
walk through an elements of an array or object one by one
Back
PHP strtolower();
Front
-changes string to lowercase
Back
PHP array_sum();
Front
-sum from an array that will return it's value
Back
PHP end of code line is signified by
Front
;
Back
PHP trim();
Front
-remove excess white space before and after string, not in between words
Back
PHP sort():
Front
-sort array by order, modifying the array in the process
Back
format of PHP FOR loop
Front
for ($var = 2004; $var < 2000; $var = $var + 2) { echo text; }
OR SHORTHAND
for ($var = 2004; $var < 2000; $leap++;) {echo text; }
these variables are basically, the start point, the condition at which to check every time, and what to run at the end of each loop or iteration
Back
PHP remove array
Front
unset($array);
Back
how to increase by 1 php
Front
++
Back
what code stops a code block once running in PHP
Front
exit;
Back
cocatenation operator in PHP
Front
.
Back
PHP foreach format
Front
foreach ($array as $element) { echo "$element"; }
Back
PHP strpos();
Front
-finds position of the occurrence of a substring in a string
Back
number of first character in a string PHP
Front
0
Back
PHP strtoupper();
Front
-changes string to uppercase
Back
PHP server or client side?
Front
server side
Back
PHP rand();
Front
-produces a random number between two numbers
-rand(min, max);
Back
stating tags of PHP
Front
<?php
Back
do you put quotes around numbers in PHP
Front
no, only strings (not including booleans)
Back
PHP when to use foreach vs while loops
Front
foreach would be best used with arrays and objects
while loops can be used for data of a different datatytpe or initialized data
Back
when do you use quotes for variables in PHP
Front
for strings, not numbers or boolean values
Back
PHP count();
Front
-count number of items in an array
-pass it an array
Back
PHP round();
Front
-rounds a number to decimal place
-round(number, number of decimal places)
Back
PHP for loops purpose
Front
good for running loops if you know how many times you are going to run a loop
Back
PHP change item in list of array
Front
$array[3] = 'newitem';
Back
PHP strlen();
Front
-gets passed a string or var containing a string
-returns number of characters in a string
Back
PHP array_push();
Front
-adds an element to an array
-array_push(array, element to add to array);
Back
do you always have to use both starting and ending tags for PHP?
Front
don't have to use the ending tag if there is only PHP In the document (No HTML)
Back
comparison operators in PHP
Front
> = greater than
< = less than
<= is less than or equal to
>= is greater than or equal to
== is equal to
!= is not equal to
Back
PHP htmlspecialchars();
Front
-treats input as regular text, not HTML.. achieves this by ESCAPING THE TEXT
Back
PHP for vs foreach loop
Front
for is technically faster than foreach for normal array loops, but not a good reason to use it because it still has bad usability. foreach is much easier to read and great for walking through elements of an object or array.
you should really only use for loops when you need to change the counter during an iteration
foreach also is able to access associative arrays, while for is not
Back
javascript server or client side?
Front
client side
Back
PHP join();
Front
-glue array items together by :
-does not actually modify the array, just returns the value and must be used with echo or print in that case
-join(":", $array);
Back
PHP header();
Front
-redirect to another page
-header("Location: contact-thank-you.php");
Back
how to comment in PHP
Front
//
Back
while vs do while loops PHP
Front
do while loops you can run a do statement block of code before the loop
Back
what do you put quotes around in PHP
Front
strings, not numbers, not booleans
Back
PHP types of loops
Front
1) FOR loops
2) FOREACH loops
3) WHILE loops
4) DOWHILE loops
5) IF loops
6) IF/ELSE loops
Back
how to echo array item in php
Front
$array[2];
will show the 3rd item
$array{2};
this also works
Back
what does 1 and 0 mean in php
Front
true, false
Back
PHP rsort():
Front
-sort array by opposite order, modifying the array in the process
-shows all the possible information about a variable including arrays
Back
why use a switch instead of if/else PHP
Front
switch only accepts certain constant datatypes, while if else accepts all
switch can fall through to the next if the break between two switches is forgotten, whereas with if/else you can't forget the break between two statements
you can leave the else in if else
switch is more compact
can't use comparison operators in switch
check if a given instance (the first variable passed) is part of a given class (the second variable passed
is_a($me, "Person");
Back
PHP array_shift():
Front
-removes one value from an array, returns the one value that was removed if stored in a variable
Back
PHP floor();
Front
-rounds integer down
Back
purpose of constructor in PHP
Front
in order to force data to be given to object when it is instantiated as an instance and disallow any instances without such data, this allows for it to be loaded right away with initialization if you need the data to be for other methods to function correctly for example
Back
PHP $_SERVER and example of use
Front
-array
-REQUEST_METHOD can be used to check request method
Back
PHP method_exists;
Front
check if an object has a given method ($me, "Person");
Back
when you are improving the code PHP without changing the functionality what is that called
Front
refactoring
Back
PHP array_reverse();
Front
-reverses the array and makes new keys starting from 0
Back
rewrite links are found in
Front
.htaccess
Back
how to make a variable that doesn't change in PHP
Front
make a constant
cont alive = true;
**don't use $ for the variable
Back
PHP how do you create objects?
Front
from classes
$obj1 = new Class;
Back
how to access in php multidimensional arrays
Front
$assoarray[2][1]
Back
how to make an non override able inheritance method? PHP
Front
use final keyword
final public function drive() {}
Back
PHP $_GET
Front
-an array usually formed by a URL submission
Back
PHP associative arrays format
Front
$assocarray = array('Swag' => 1, 'Swag2' => 2);
Back
how to make a rewrite rule in htaccess
Front
RewriteRule (URL YOU ARE REFERENCING) (WHAT URL TO LOAD)
sooo
RewriteRule ^shirts/$ /shirts/shirts.php
Back
php what are these in php associative arrays X => Y
Front
key => value
Back
can the first number of a PHP variable be a number?
Front
NOPE
Back
do you always need both opening and closing PHP tags
Front
only need opening tag if all the code in the document is PHP
Back
PHP empty();
Front
checks if an array is empty.. if empty is returns boolean true
Back
PHP how to return a value within a statement without actually displaying it
Front
return();
Back
do search forms in PHP use GET Or POST
Front
GET
Back
in htaccess how to redirect and tell the search engine that it is a permanent effect
Front
add [R=301] to the end of a redirect
Back
PHP $this
Front
allows you to access properties in a class
Back
how to check request method in PHP
Front
$_SERVER['REQUEST METHOD']
Back
how do you access static variables in PHP
Front
::
if(Class::$variable) {}
Back
MVC PHP
Front
MODELS --> page that contains data
VIEW --> page when it displays content
CONTROLLERS --> determines which methods to call from models
Back
standard naming of html partials
Front
partial-name.html
Back
how do you use $this to access a property
Front
$this->obj1
**dont use the $ on the variable when accessing it
Back
in htaccess what does the $ mean
Front
it means the end of a url
Back
in htaccess what does ^ mean
Front
everything before, the root url basically before the htaccess file
Back
PHP instance vs objects
Front
instantiated objects, they become things instead of just definitions
Back
how to access associative array values
Front
assocarray[key];
Back
htaccess how to check for a GET request
Front
use RewriteCond with the following to check for different numbers
then write a query string like the following:
%{QUERY_STRING} ^id=[0-9]+$
the + sign means that any number of characters is fine
Back
PHP intvalue();
Front
-if integer, returns boolean true
Back
PHP objects contain
Front
methods(functions) and properties(variables)
Back
what to start htacess with
Front
ReWriteEngine On
--> turns rewrite engine on
Back
php what is the point of the using a static keyword
Front
when you want to use a method or variable that is not tied to an instance
Back
are PHP variables case sensitive?
Front
yes
Back
how do you access constants in PHP
Front
you use the :: with Class::constant
if(Class::constant) {}
Back
PHP $_POST
Front
-array made through form submissions
Back
what signifies end of commands in rewrite links of htacess
Front
nothing, just paragraphs
Back
purpose of pre tags in PHP
Front
to show whitespace in browser (preserves both line breaks and spaces in browser)
Back
PHP property_exists;
Front
check if an object has a given property
Back
what are html Partials
Front
small snippets of code that are reused
Back
PHP what are instances
Front
objects within classes
Back
types of links in PHP
Front
1) relative links (uses ../ and folder refs)
2) absolute links (use http)
3) root-relative links ( start with / and starts at the root)
4) constants which can have a variable that defines the base url and then append the end of the url on (BASE_URL and ROOT_URL) concatenated with other directories
5) absolute server links --> use /User/Desktop etc for desktops and $_SERVER["DOCUMENT_ROOT"] for web servers
Back
what is scope resolution operator in PHP
Front
accessing static and const in PHP using ::
Back
php what differentiates static and const variables
Front
const are always public, whereas static are default public unless specified
static variables can be changed
Back
Section 3
(50 cards)
what does it mean that PHP is WEAKLY TYPED
Front
it doesn't really care what type of data you store in a variable
Back
fatal error in PHP
Front
HTML prior to the error will be displayed, but everything after won't be
CAUSE --> referring to a nonexistent file or function
Back
do quotes have to be matching in PHP strings
Front
yes
Back
PHP combined assignment operators
Front
$a += $b is equal to $a = $a + $b
Back
how to subtract in PHP
Front
-
Back
how to add PHP comments
Front
1) //
2) #
3) //
Back
when you are using too many escape sequences in PHP, what might the better option be?
Front
to use HEREDOC SYNTAX
Back
inequality in PHP
Front
!=
Back
what is the number of a value in a regular array called
Front
key
Back
$_SERVER php
Front
get information from the web server
Back
strict error in PHP
Front
warns about techniques that are not considered good practice
Back
what does = mean in PHP
Front
assignment operator
Back
recoverable error in PHP
Front
occurs when an exception error is thrown
Back
anything between DOUBLE quotes in PHP is treated as
Front
regular text
escape sequences that can process variables and special characters
1) --> insert new line char
2) \r --> inserts carriage return
3) \t --> inserts tab
Back
what is modulo division in PHP
Front
use % and it will return the remainder of the division
Back
$_GET php
Front
get info passed via http get method
Back
what does PHP determine as implicit false boolean value
use the built in PHP classes to auto throw a specific exception
catch it with a separate code block after wrapping main script in a try block
the catch block can redirect user to an error page
Back
how to do AND in PHP
Front
&&
Back
how to use else if php
Front
if (cond true) {//code} else if (second cond true) { //first false, second true} elseif {//both are false}
Back
superglobal arrays in PHP all begin with
Front
$_
Back
$_SESSION php
Front
to create simple login systems
Back
$_POST php
Front
get info passed via HTTP post method
Back
how to get document root of your server in PHP
Front
$_SERVER['DOCUMENT_ROOT']
Back
how to increment +1 in PHP
Front
++
Back
identical in PHP plus what does it mean
Front
===
means same value AND data type
Back
parse error in PHP
Front
mistake in code syntax, stops and doesn't allow for HTML output
Back
how to force a variable to a specific type in PHP
Front
$types = (array) $types;
forced into an array type
Back
warning error in PHP
Front
serious problem such as include file missing, but rest of output is still processed
Back
deprecated error in PHP
Front
warning that features are scheduled to be removed in the next major version of PHP
script COULD suddenly stop working in the future
are boolean values (true/false/null) case sensitive?
Front
no, they are case insensitive
Back
how to divide in PHP
Front
/
Back
how to inspect an array in PHP and print the contents
Front
print_r($array);
Back
anything between SINGLE quotes in PHP is treated as
Front
literal text
Back
superglobal arrays PHP
Front
built into PHP and are automatically populated with useful information, such as POST and GET
Back
how to get the domain name of a website in PHP
Front
$_SERVER['HTTP_HOST']
Back
what can you do in PHP if there is punctuation in a PHP string
Front
1) could use double quotes
2) could precede apostrophes with a backslash (escaping)
Back
how to do OR in PHP
Front
||
Back
when to use single or double quotes PHP
Front
single = all the time unless string contains variables
Back
in PHP is the error usually where the line PHP discovered the problem?
Front
no, most of the time PHP is telling you that something unexpected happened, and the mistake lies before that point
Back
type of arrays PHP
Front
index arrays
associative arrays
multidimensional arrays
superglobal arrays
Back
how to multiply in PHP
Front
*
Back
is there any points where you don't need to include a semicolon at the end of a PHP line?
Front
if there is only one statement in a code block, but even then it is bad practice
Back
how to add in PHP
Front
+
Back
notice error in PHP
Front
occurs when you have a small issue such as usage of a non declared variable, and the page will still display
Back
assignment operator in PHP
Front
=
Back
Section 4
(16 cards)
can PHP Use AND/OR
Front
yes, but it is not advisable, stick to && and ||
Back
pass by reference PHP
Front
function(&$variable) { }
the code will do anything to the variable that will last outside of the scope because it modifies the actual variable
Back
besides switch and if/else what can you use for conditional statements PHP
Front
TERNARY OPERATOR --> ?:
Back
good practice when storing functions
Front
put them all at the top of bottom of one page if being used in one page only
put them in a ext file and include them if being used in multiple pages
Back
how can you adjust your PHP include path
Front
1) edit php.ini value
2) use htaccess
3) use set_include_path(); --> LAST RESTORT because it affects the path only for the current file
Back
SSIs PHP
Front
server side includes
Back
dangers of while loops PHP
Front
can cause infinite loop and browser to crash
Back
when should you use require instead of include PHP
Front
for when you NEED classes for the code
Back
diff between include and include once (and same for require) PHP
Front
the _once makes it so that the file can only be included on one page
Back
diff between if/else and ternary PHP
Front
if/else easier to read, ternary is more compact
Back
diff between include and require PHP
Front
if include can't find the external file, it will continue to process the page
require will throw a fatal error
Back
scope of functions PHP
Front
when a variable is being manipulated within a function, it does NOT retain scope outside of that function
UNLESS you use the return keyword and assign the result to either the same variable or another variable
OR pass by reference and it will modify the actual variable