Computer Science 60-270 Final: Review Guide

7 Pages
Unlock Document

University of Windsor
Computer Science
Numanul Subhani

FINAL EXAM REVIEW (non-cumulative) PHP - Server Side Scripts  Supports both single- or double-quote  Escape sequences  are special characters: tags, new line, dollar signs  You have to put a skip character (a back slash) in front of that special character in order for PHP to recognize the special character o Ex. \$  it will print the $ sign Arithmetic Operators and Expressions  Floor  automatically rounds down to the absolute number o Ex. floor(12.02) = 12  Ceil  automatically rounds up o Ex. floor(12.52) = 13  Round  rounds a floating-point number  Srand  seeds a random number (random number generator) String Operations  Strlen  length of the string  Strcmp  it will return a Boolean value compared to a string  Strtolower  converts upper case to lower  Strtoupper  converts lower case to upper  2 + "2"  when you add a number to a string, the string will convert into a number, which is 4  But "2" + 2 becomes 22 o Ex. 2 + "two" = error; "two" + 2 = two2  It normally takes whatever type in the front  Thus, in PHP, you have to give the command to convert Conversion  You're converting a string into integer type using (int) o $age = "21" o $numb_age=(int) $age  Intval  converts a string but gives you your value unlike the first kind  Settype  is exactly the opposite of the first kind; you're setting a type of whatever and changing it into an integer Creating a Numeric Variable  In javascript, you open with ..  In PHP, you must open it with  php codes start at the  pow is a function in php, used in javascript too  power; taking a number and state the number of power (2 = square the number, 3 = 3 cubic number)  The amount of number is the number of rows in the table  print date is a date function  setting the date format Arrays  foreach function normally works only for arrays  Key is the index and value is the array value o Taking each element from the start and end of the array and printing all of it  Difference between what servers see the script and what the clients see  You won't see php script o same as javascript  clients only see internal javascript codes, but not external More Notes on PHP  PHP  PHP Hypertext Preprocessor; scripts that are executed on the server and result returns to the browser as plain HTML  PHP file contains text, HTML, CSS, JavaScript, and PHP code  Has extension ".php"  It can: o Generate dynamic page content o Create, open, read, write, and close files on the server o Collect form data o Send and receive cookies o Add, delete, modify data in your database o Restrict users to access some pages on your website o Encrypt data  Always starts with  Comments in PHP can be //, #, and /* */  Rules for PHP variables o A variable is created the moment you first assign a value to it o Must be identified with a $ sign, followed by the variable name o Are case-sensitive o Must start with a letter or the underscore character o Cannot start with a number o Can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )  PHP is loosely type language  automatically converts the variable to the correct data type, depending on its value  In PHP, variables can be declared anywhere in the script  Three different variable scopes: local, global and static o Global scope  a variable declared outside a function and can only be accessed outside that function o Local scope  a variable declared within a function and can only be accessed within that function  The Global Keyword  used to access a global variable from within a function, for example: function myTest() { global $x,$y; $y=$x+$y; }  PHP stores all global variables in an array called $GLOBALS[index], which holds the name of the variable  Array is accessible from within functions and can be used to update global variables directly, for instance: function myTest() { $GLOBALS['y']=$GLOBALS['x']+$GLOBALS['y']; } The Static keyword  When a function is completed/executed, all the its variables are normally deleted. However, sometimes we want a local variable NOT to be deleted so we use the static key when first declare the variable (variable is still local): function myTest() { static $x=0; echo $x; $x++; } Accessing Server Files  “r”  read only  “r+”  read and write an existing file  “w”  write only an existing file or it creates a new one  “w+”  read and write an existing file or it creates a new one; at the beginning of the file which will destroy any existing data “a”  write only; at the end of the file   “a+”  read and write an existing file (at the end of existing data) or it creates a new one  fopen function will open the file and fclose function will close it Get and Post  Get  retrieves info from a server  Post  sends data to a server  server-side software  allows users to enter username and password (authorized users can update the inventory)  to collect username and password, website can use a form with post method $USERNAME = $_POST["USERNAME"]; $PASSWORD = $_POST["PASSWORD"]; Databases  Each category of info is a field (displayed in columns in database) o ex. first name, last name, age, phone number  Group of fields is a record whereas group of records is a table  Advantages o can easily store and retrieve large amount of info o info can be shared o can ensure data integrity (da
More Less

Related notes for 60-270

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.