CMSY-203-050 Introduction to PHP 2020SP

From CatholicKnowledge
Jump to navigation Jump to search
  • CMSY-203-050 Introduction to PHP:
  • Professor: : Janak Rajani
  • Taken : Spring 2020
  • Description: PHP is an open source server-side scripting language used to create dynamic, data-driven Web sites for such applications as web-based content management and display systems. It performs many of the same functions as ASP and Cold Fusion. In this course, students will learn how to use several features of this scripting language. Students will write scripting code within the class and in assignments outside of class.

Class materials on: Howard Community College Canvas


Google drive

Test server on CatholicKnowledge

Go back to Class Listing School stuff

Syllabus

Required Reading:

Textbook:

Assignments:

Course Schedule

PHP Code

PHP code exampes

Notes

Terms

A

  • Arithmetic binary operators are used in PHP to perform mathematical calculations (+ - x ÷ %)
  • arithmetic unary operators ++ increment, -- decrement. Can be written as prefix operator which is placed before a variable, or postfix operator is placed after a variable
  • arguments or actual parameters - the data (in parentheses following the function name) are called arguments or actual parameters
  • array contains a set of data represented by a single variable name
    • An element refers to each piece of data that is stored within an array
    • An index is an element’s numeric position within the array referenced by enclosing its index in brackets at the end of the array name e.g. $Provinces[1]
  • Assignment operators are used for assigning a value to a variable: e.g. $MyFavoriteSuperHero = "Superman";
  • Associativity - the order in which operators of equal precedence execute

B

  • Boolean value is a value of true or false. It decides which part of a program should execute and which part should compare data. In PHP programming, you can only use true or false

C

  • Casting or type casting copies the value contained in a variable of one data type into a variable of another data type. The PHP syntax for casting variables is: $NewVariable = (new_type) $OldVariable; (new_type) refers to the type-casting operator representing the type to which you want to cast the variable
  • code declaration blocks are separate sections within a Web page that are interpreted by the scripting engine
    • standard PHP script delimiters <?php … ?>
    • the <script> element
    • short PHP script delimiters <? statements;?>
    • ASP-style script delimiters <% statements; %>
  • comments - nonprinting lines placed in code such as:
    • block comments hide multiple lines of code add /* to the first line of code and */ after the last character in the code
    • line comments hide a single line of code - add // or # before the text
  • Comparison operators - used to compare two operands . A Boolean value of true or false is returned. Comparison operators are used with conditional statements and looping statements i.e ==, ===, !==, >, <, <=, >=
  • Compound assignment operators - perform mathematical calculations on variables and literal values in an expression, and then assign a new value to the left operand
  • conditional operator executes one of two expressions, based on the results of a conditional expression
    • The syntax for the conditional operator is: conditional expression ? expression1 : expression2;
    • If the conditional expression evaluates to true, expression1 executes, if the conditional expression evaluates to false, expression2 executes
  • constant contains information that does not change during the course of program execution. Constant names do not begin with a dollar sign ($), Constant names use all uppercase letters Use the define() function to create a constant define("CONSTANT_NAME", value);

D

  • data type is the specific category of information that a variable contains.
  • declaring a variable - Specifying and creating a variable name is called In PHP, you must declare and initialize a variable in the same statement: $variable_name = value;
  • delimiter is a character or sequence of characters used to mark the beginning and end of a code segment

E

  • expression - a literal value or variable that can be evaluated by the PHP scripting engine to produce a result
  • embedded scripting languages (JavaScript or PHP) refer to code that is embedded within a Web page
  • Exponential notation, or scientific notation, is short for writing very large numbers or numbers with many decimal places (2.0e11)

F

  • floating-point number is a number that contains decimal places or that is written in exponential notation (-6.16, 3.17, 2.7541).
  • function refers to a procedure that performs a specific task
  • function call is the function name followed by any data that the function needs

I

  • integer - a positive or negative number with no decimal places (-250, 2, 100, 10,000). One of the two data types supported by PHP. The other is floating point.
  • initializing a variable - Assigning a first value to a variable In PHP, you must declare and initialize a variable in the same statement: $variable_name = value;

L

  • literal is a value such as a literal string or a number
  • logical operators - used for comparing two Boolean operands for equality. A Boolean value of true or false is returned after two operands are compared. i.e && - and, || - or, ! - not

O

  • Operands - variables and literals contained in an expression
  • Operator precedence refers to the order in which operations in an expression are evaluated
  • Operators - symbols +, -, *, /, % that are used in expressions to manipulate operands


  • passing arguments - sending data to a called function
  • primitive type Data types that can be assigned only a single value ie. integer, floating point, string and numm
  • programming language construct - a built-in feature of a programming language
  • query: a structured set of instructions and criteria for retrieving, adding, modifying, and deleting database information.

R

  • resource data type – a special variable that holds a reference to an external resource such as a database or XML file
  • reference' or composite data types, which contain multiple values or complex types of information e.g. arrays and objects


  • statements individual lines of code that make up a PHP script.

T

  • text string, or literal string, is text that is contained within double or single quotation marks
  • typing (data) -
    • Strongly typed programming languages require you to declare the data types of variables
    • Static or strong typing refers to data types that do not change after they have been declared
    • Loosely typed programming languages do not require you to declare the data types of variables
    • Dynamic or loose typing' refers to data types that can change after they have been declared
  • variable - The values stored in computer memory are called variables
    • The name you assign to a variable is called an identifier
    • Must begin with a dollar sign ($), Cannot include spaces, Is case sensitive