ITC 280 Class Notes 4-18-11
Skin – like a style applied to website
Template & Theme : interchangeable but are slightly different ???
Webpage – web application: can have the same page but have multiple applications built into the same address
· Similar to a form handler (various files can be on multiple servers) you don’t need to have them all in one server
· In class, we will have them all in one file (but real world, this is NOT a requirement)
Assignment 3: intentional errors (one error can have 10 warnings related to that error)
· Goal: to learn something
· (lesson 5 is on there more than a week) – to ask questions for class
Lesson 5 & 6: conditionals & how to apply them to form handlers
Lesson 7: regarding A3
CONSTANTS: “constantly available”, exists globally, defined in all caps (in quotes) and given a value as the 2nd attribute in the parentheses)
· no $ sign for constants
· NEVER put space between define & ( )
o Recommended so that it keeps things short
o NOTE: use a period for concatenate would need a space to show it better
Conditional Statements
ex: if(PAY > 40000){ }
· Open up statements, could read code without white space
· BILL likes to keep the code horizontally more so than vertically
o He likes to condense them in one line, esp repeating code
ECHO replacement (use double quotes), less escape characters
Variable replacement (taking what you “echo” and replacing the hard code with variables that you have declared
NOTE: php will be confused when you are doing an assignment “=” when you mean comparing “==”
BUILDING FUNCTIONS:
HOW TO:
You copy, paste the working code, when it works, comment it out from the physical code and just call the function (Saves you the re-writing/troubleshooting time)
You copy, paste the working code, when it works, comment it out from the physical code and just call the function (Saves you the re-writing/troubleshooting time)
Requirements:
Parameter - what goes in the ( ),
Argument - variable passed into function, what function receives to work with
Parameter - what goes in the ( ),
Argument - variable passed into function, what function receives to work with
Example #2 Passing function parameters by reference
<?phpfunction add_some_extra(&$string)
{
$string .= 'and something extra.';
}$str = 'This is a string, ';add_some_extra($str); // function callecho $str;
// outputs 'This is a string, and something extra.'?> Make sure you name your function to something logical
· Camel case or use “_” the two or more word names
· { } arguments & attributes
· data goes in and it gets changed, commonly used to process data going in
o like a car wash, same stuff goes in, altered stuff goes out
· functions normally do not have echo statements because it gets printed and executed every time it gets called
o if echo is in function, can’t “process it” (can’t modify it, it is hard-coded)
· FUNCTIONS are NOT in sequence, they are independent and can co-exist within themselves. They are only relevant when they are being called, “it is its own harbor”
o Classes are also out of flow of the code (in any programming program)
· Computer puts all the functions in memory, pending
o Goes to the top of the top of the code
o NOTE: functions should be DOING something otherwise, you are wasting memory
o Comment multiple lines /* */
· Storing data:
o Neutral value: $myReturn = “”; (Create a variable of zero length)
§ Boolean: $myReturn = false;
§ Number: $myReturn = 0;
· Select & replace
o Highlight the code > under “Search” > “Find” and you take all the “echo” out and replace it with “.=” since echo is forbidden in a function
· Include files: convenient when you know that functions work, you don’t want to mess with it, so you put it in a separate include file
o include 'include/myfunctions.php'; // to hide the functions and not have to deal with them in here
PROGRAMS: (for macs
Coda: alternative to Dreamweaver - $99, 14 day trial
WEB APPLICATION: Implies a process
· log in
· build a form
o form handler 1
§ feedback 1
o form handler 2
§ feedback 2
o form handler 3
§ feedback 3
GOAL: building a web application all in one file
Anatomy Of A Web Application
Fundamentally a web application is built of 3 parts:
- Form
- Formhandler (can be combined with 3)
- Feedback (processing area)
Focus: in the middle (header & footer does not change)
-If statement: does two things, if there is data to be done
-form action:
//REQUIREMENTS: if it sends data, it needs to send it to some place, can be sent in itself
-form action:
//REQUIREMENTS: if it sends data, it needs to send it to some place, can be sent in itself
snapshot of the page & it pastes it back to the client (data floating in memory to do anything and go anywhere)
· INPUT "type” attribute is the most important, because it tells you the string input
· Defaults to “type” if attribute isn’t defined
· “name” attribute is important when you want to address it
METHODS: “get” does not like forms
What is the default method? It is normally “get” but you want to “post” to load a queue string postback1.php?FirstName=Vy
Syntax:
if(isset($_POST['FirstName'])) // 'isset' if data is being sent to us or not
{
}
Assignment 2: Used the Winterbreeze template and tweaked it as my own. The footer will go up when scrolled down.
Error encounters: when cutting and pasting between the files, make sure to put stylesheet in the root folder and not in any other folders. Images will NOT show up when I put the stylesheets in the "include" folder
Assignment 2: Used the Winterbreeze template and tweaked it as my own. The footer will go up when scrolled down.
Error encounters: when cutting and pasting between the files, make sure to put stylesheet in the root folder and not in any other folders. Images will NOT show up when I put the stylesheets in the "include" folder
No comments:
Post a Comment