Total Pageviews

ITC 280 Week 2


ITC 280 – Class Notes 4-12-11

Review:

Dreamweaver will allow you to make php files from any given website
Always recommend Secured FTP (SFTP)
google hacking: a search engine can easily look in a web folder
    web folder – “public_html” INDICATION of web root viewable to anyone (do not store secure files here)

    google.com  --- “filetype:xls” things that are being indexed will be pulled up

Contract: make sure when you recommend things for your client, you always have it written down that you recommended a safer version for them so that you don’t get in trouble later

Lesson 3 – php development

Advice: Documentation is VERY important
            php – cascade structure
header is a file
index is a page
Server Directory Structure: Careful use of the directory structure is an advantage to a developer. Below is the suggested directory structure for your site, with some descriptions of the purpose and contents of the directories:
Directory Name
Contents
Note
/ (the web root, no sub folder)
Your index.php page and all main linked php pages
End all pages with .php extension, for possible later additional code.  Remember the folder for web files has an alias, for example "public_html".
/images/
All image files for the site, spacer GIFs, etc.
Customary isolation of image files
/include/
All non-image included web files, CSS, JavaScript, etc.
Supporting files that are pieces & parts - these will be only web files (stylesheets and JavaScript files) as later we'll create a special folder for PHP include files
/upload/
all read/write/executable files
Isolate any files that are writable as the directory that is writable presents security issues
/demo/
All test pages and model pages we are using for reference
Separate files that support your development from the necessary site files - these files would be removed when work on a site is complete
/sandbox/
all example & trivial test files we are working on
ITC280 class examples go here - these files would be removed when a site is done

Development software: as long as it doesn’t get in your way with the tools
Windows SOFTWARE: free software list
WinSCP – windows secure FTP  software (altnerative to FileZilla)
Komono Edit – windows based, but slow
Crimsonfree & open source
            “Alt+C” column mode: being able to rip or add text in one little column
Notepad++ - you want to save the file with an extension (doesn’t do it by default)
            if you have the same name of a file (which one is which) has a COMPARISON FEATURE, (under macros /plugins and you compare them)

Zend Studio – php development  environment (ultimate commercial grade application)
 (Zev & Andy were the two that redesign php)

Zend Delight: for Aptana plugin


Mac Software: free list

TextEdit:
TextWrangler:
Cyberduck

Server:

http://zephir.seattlecentral.edu/~username/

Daily Folders:
On your development machine, to keep from overwriting work, and to store work on previous versions of dynamic pages, I suggest keeping daily directories from which to work. This means you create a different directory every day, on your main development machine, with today's date, for example:
/20040406/ (folder should be dated like this, not the file)

work with files that work, & date them based on what you are working on (gives you more than one version) so you know where it works until you have broken it later down the line

 NOTE: never create an assignment folder ( you don’t need it, your assignments will build on one another)
Creating folders:
>dev>04122011>itc280>
   NOTE: only save stuff that WORKS in this folder (don’t keep broken files in archive)
/upload/  folder

Starting a PHP in text editor:
<?php
….
Echo ‘My name is vy’;

?>             //rules of php applies (no space between the “?”)
// NOTE: you can jump in and out of php stuff, this renders as pure text
right click folders & files> properties  under “Octal” make sure it is “0775” or “0755” gives you the maximum access on your folder
NOTE: you CANNOT put html in php sections but you can put <html> stuff in php stuff
   -
PHP code can be interspersed between sections of regular HTML, as often as we wish. As long as the script tags are opened and closed properly, there is no conflict.
You always want to put the name of the php file after you declare a <?php
Output: view code, will not view any php stuff because this is on the server side
      NOTE: if you get to the end, and there is no other code under it, you don’t need to close php tags
Variables: usually use strings unless you are using the numbers to compute something
   $_____ : indicated by the $ sign
            prefix “my” are usually never indicated in any reserved naming convention
            floating memory on the server (note: javascript is floating memory on user side)
In php the “ . “ as a connector between strings

When it works with data, it does NOT have hard and fast rules, scripting language
            can assign any name to variables – you can declare things and are “loosely typed”
                  and will “silently accept things” and sometimes will make things blow up

Examples of “loosely typed”
- javascript (connector is the “+”)
- vb script (connector is the “&”)
Concatenating is the same as “connecting”
            taking pieces of string and pieces of variables and tacking them together
            The context you use helps determines how php stuff is being combined
              Ex: 
$num1 = 25;
         $num2 = “5”;
         $total = num1 + num2;
 
        echo ‘My total is ‘ . $total . ‘.’; // will still add the numbers correctly

you need to keep your contact straight

SQL is good for “” whereas
   // the backslash is to get out of the quote
Single quotes
Double quotes
O’Malley the “O\’Malley”  is how you would write it

COMMANDS: (programming is ALWAYS read right to left)

The significant side is always on the left
“=” assignment operator
“==” comparison operator
“ . ” addition operator
“\” escape character

Attributes in php require it to be in double quotes
single print quote is handy when you want to do multiple html line code
<?php
echo
'
<div align="center"><font color="red">This has double quotes!</font></div>
<div align="center"><font color="red">This has double quotes!</font></div>
<div align="center"><font color="red">This has double quotes!</font></div>
';

?>
Delivered all of the above html without having to repeat the echo statement

Variable replacement


Short Tags: Every once in a while in a PHP page you'll see an equal sign in front of a variable, which is a short cut for displaying it's contents: (NOTE: it might not be supported in PHP 6)
<div align="center"><font color="red"><?=$myName;?></font></div>

NOTE: variable replacement in Lesson 2, then we will be covering Lesson 5 next class

NOTES:

 

Class Notes: 2-13-11