Your SlideShare is downloading. ×
Mdst 3559-02-15-php
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Mdst 3559-02-15-php


Published on

Published in: Technology

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. PHP
    MDST 3559: DataestheticsProf. Alvarado02/15/2011
  • 2. Business
    Assignment grades will be posted in Collab
  • 3. Review
    JavaScript is a client-side language
    Controls behavior of the document
    Works on the document as a data structure
    jQuery is a JavaScript library
    Makes working with JavaScript easier
    Uses CSS selectors to access and manipulate document elements
  • 4. jQuery Libraries
    Core library, provides selectors and basic effects
    jQuery UI
    Provides user Interface functions, e.g. Tabs (See Demos)
    Hundreds of functions and effects
  • 5. Another jQuery Example
    Create a class for notes that can be turned on an off
    Show jQuery features:
    Manipulation: new text added
    Traversing: moving between elements
    Dynamic CSS: add styles dynamically to elements
  • 6. Overview
    Today we shift to PHP – a server-side programming language
  • 7. Client vs. Server Side
    All programs are human written sequences of commands that control the computer
    Programs are first “compiled” into a machine language
    When a program is “executed,” it produces an effect
  • 8. Client vs. Server Side
    In web programming, web pages can have either server-side or client-side programs embedded in them
    Server-side code gets executed before the page is delivered to the browser
    Client-side code gets executed after the page is delivered to the browser
  • 9.
  • 10. PHP
    PHP is a simple server-side programming language
    It was invented in 1994 by RasmusLerdorf, a Danish Canadian, as a way to simplify the process of writing server-side programs
    These older programs were called “CGI scripts”
    Originally PHP stood for “Personal Home Page,” now it just means PHP ...
  • 11.
  • 12. Exercise 1: Hello, World!
    Create a new file, hello.php
    Create an H1 Element called “Introduction to PHP”
    Create an H2 Element called “Exercise 1”
    Enter the following code:
    echo “Hello, World!”;
  • 13. Observations
    PHP files must end in .php
    Otherwise, not executed, treated as text
    PHP code must live inside of the opening and closing “tags” <?php and ?>
    This looks like XML but it is not
    Anything outside of these tags is regular content, e.g. plain text, HTML, or XML
    echo is just a function that prints its argument to the screen
    echo does note require parantheses
    Your browser knows nothing about the PHP
  • 14. Exercise 2: Variables
    Comment out your first echo statement
    Define a variable to hold the string “Hello, World!”
    Use echo to print the variable to the screen
  • 15. Variables
    Always prefixed by $
    Variables hold values
    VariableS are assigned values with the = sign
    Variables are always on the left
  • 16. Exercise 3: Variable Types
    Comment out your last echo statement
    Create a new variable called $notd (for “number of the day”) and give it a numeric value, e.g.
    $notd = (42 * 5) + 29;
    Do not use quotes
    Append text to your message variable
    $message .= “The message of the day is: ”;
    Then echo the message and the notd together
    echo “$message $notd”;
  • 17. Observations
    Values can be strings, numbers, or other things
    Strings are always quoted (in single or double quotes)
    Numbers are never quoted
    Number can be the result of an equations
    Operators: + - * / (also: ^ and %)
  • 18. Exercise 4: Arrays
    Create a new file rex.php
    Invoke the file() function to grab a file from the web and assign the return value to the variable $contents
    Use the URL from post [8.1] on the blog
    $url = '.’;
    $contents = get($url);
    Invoke echo to print out $contents to screen
  • 19. Observation
    What do we see?
    PHP is telling us that $contents is an array, not a string
    What is an array?
  • 20. Arrays
    Arrays are built-in data structures in the PHP language
    A data type that holds other data types (strings, numbers, other arrays)
    Each stores a list of values
    The items in the list are indexed a number starting with 0
    Let’s look back at our example ...
  • 21. Exercise 5
    Iterate through the $contents array using the foreach() function
    Then iterate through the $contents array using the for() function
  • 22. Observations
    Arrays have a length, or size
    The size is always 1 greater than the last index value
    Since the index begins with “0”
    Iterating through arrays allows you to modify each item in the array
    Text files are often represented as arrays
  • 23. Exercise 6
    Using the foreach() function, format each line
    Skip the first 5 lines
    Remove the trailing new line
    wrap each $line in paragraph tags