PHP stuff pt. 1

About this set

Created by:

sharkjohnson  on July 22, 2010

Subjects:

php, programming

Description:

so I got a book and I want to learn it up.

Log in to favorite or report as inappropriate.
Pop out
No Messages

You must log in to discuss this set.

PHP stuff pt. 1

set of rules that dictate how you write programs in a language.
Lexical Structure
1/46

Study:

Cards (new!)

Learn

Test

Speller

Scatter

Games:

Scatter

Space Race

Tools:

Export

Copy

Combine

Embed

Order by

Terms

Definitions

set of rules that dictate how you write programs in a language. Lexical Structure
are function names case-sensitive? no
are class names case-sensitive? no
what class name is reserved? stdClass
how do you make a constant and echo it? define('Truth', 'Mark');
echo Truth;
what's a synonym for a reserved word? a keyword
floating point number numbers with decimal digits
how can you test to see if a number has decimal digits? is_float()
what do you call variables in classes? properties
how do you create a new object? $obj = new Class
($ed = new Person)
a resource is... a handle is ...
where do you really see the benefit of automatic cleanup of the $dbc handle? when it's a local variable (in a function). then it disappears when the function ends.
is NULL case-sensitive? no
how do you test if a $var has been initiated with null? if ($unititiated_Var === null) echo 'yea';
how can you make a value in a variable a variable itself with its own value? $foo = 'bar';
$$foo = 'baz';
now $bar = 'baz'
how do you make a variable reference for $white? $black =& $white;
now $black's value will always be $white's (and vise-vera). You can also do this sort of thing with functions (but it's a little weirder)
what's the relationship between local and global functions of the same name? they are totally isolated from each other.
what is a static variable? a variable that retains its value between calls to a function (but is still local)
what is a symbol table? an array that maps variable names to the positions of their values in memory.
how does PHP save memory when you write $var1 = $var2? Instead of copying the data from $var2 into $var1, it updates the symbol table to say "both of these variables represent the same chunk of info". It only makes a copy when you change some info in one of the variables.
what is "copy-on-write"? Instead of copying the data from $var2 into $var1, it updates the symbol table to say "both of these variables represent the same chunk of info". It only makes a copy when you change some info in one of the variables.
what's a reference count? the number of ways to reference a particular value (this number is also stored in a symbol table)
what can decrease a reference count? (2 examples) 1) if a variable goes out of scope
2) if you change something in a $var1 so $var2 (it's 'copy') becomes different.
(there are others)
what happens if a variable's reference count reached 0? it's memory is released.
how can you free a variable's memory manually? unset()
what is operator associativity using 2/2*2 as an example? If two operators have the same precedence (like '/' and '') then associativity determines which terms we evaluate first. / and are left-to-right, we calculate this expression as (2/2)*2
what is casting? the conversion of one type of a value to another type.
type juggling implicit casting (conversion of one type of a value to another type) via arithmetic operations (like if a string is the second operand and an integer or floating point is the first, then the string type will be converted to match)
how does PHP calculate the numeric value of strings? (2) 1) if no number is found at the beginning of the string, then its numeric value is 0
2) if is contains a '.' or an 'e'/'E', then any number in it will evaluate as a floating-point number
what is "9 Lives" - 1? 8 (int)
what is "3.14 Pies" * 2 6.28 (float)
what is "9 Lives." - 1 8 (float)
what is "1E3 Points of Light" + 1 1001 (float)
how do you convert an array ($a) to an object ($o)? $o = (object) $a;
how do you quickly add 5 to a variable? $a +=5;
how do you end a "while" loop early? break;
how do you end a "while" loop as well as the other "while" loops it (may be) buried within? break 2 (where "2" is the number of loop levels.
how do you stop an inner loop early but let the outer loop keep going? continue 2 (where "2" is the # of loop levels)
how do you write
$counter = 0;
while ($counter < 10) {
echo "counter is $counter\n";
$counter++;} as a "for" statement?
for ($counter = 0; $counter < 10; $counter++) {
echo "counter is $counter\n"; }
what are loop expressions? 1. while
2. do/while
3. for
4. foreach
can you use "break" and "continue" with a "for" loop? yes!
when do you use "foreach"? when you want to iterate over elements in an array.
what is structure of "foreach"? foreach ($array as $current) or ($result as $row)
what is the "foreach" structure to use when you want to access both key and value? foreach ($array as $key->$value)
how do you execute some_function() after every third statment in a loop is executed? register_tick_funtion("some_function");
declare(ticks = 3) {for($i=0; $i<10; $i++){...}}
do you need parenthesis with "include"? no!

First Time Here?

Welcome to Quizlet, a fun, free place to study. Try these flashcards, find others to study, or make your own.

Set Champions

There are no high scores or champions for this set yet. You can sign up or log in to be the first!