PHP - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

PHP

Description:

Wordpress. Drupal. Joomla. Moodle. PHP: The Bad. Extremely loose structure invites sloppy coding. ... PHP was designed to add programming logic to HTML pages ... – PowerPoint PPT presentation

Number of Views:123
Avg rating:3.0/5.0
Slides: 21
Provided by: Stude8
Category:
Tags: php | wordpress

less

Transcript and Presenter's Notes

Title: PHP


1
PHP
  • A Server Side Programming Language

2
PHP The Good
  • Easy to develop and deploy
  • Excellent Documentation
  • http//www.php.net
  • PHP powers some successful projects
  • Mediawiki
  • Wordpress
  • Drupal
  • Joomla
  • Moodle

3
PHP The Bad
  • Extremely loose structure invites sloppy coding.
  • PHP was designed to add programming logic to HTML
    pages this muddies the view and controller
    layers of your application

4
PHP
php code to be executed before document is
served to the client
5
PHP
  • Files have a .php extension
  • Are not complied
  • Are stored in your web servers document tree
  • .php files are parsed by the php engine before
    they are sent to the client
  • Code between is computed and the
    resulting text is sent to the client

6
Variables
  • Almost always local
  • Implicitly Typed
  • Variables can be forced to a data type
  • http//www.php.net/manual/en/language.types.type-j
    uggling.php

7
Variables
  • Superglobals
  • Contain system information
  • Are pre-named (reserved)
  • Start with _
  • _GLOBALS
  • _SERVER
  • _POST
  • _FILES
  • _COOKIE
  • _SESSION
  • _REQUEST
  • _ENV

8
_GET
  • Array of variables passed to the script with the
    query string

Get request
Query string
php code prints out the value of var1in this
case stuff
9
_POST
  • Array of form data posted to your script
  • Example file http//www.rpi.edu/gillw3/websys/ph
    p/ex1.php
  • Make a PHP script that allows the user to change
    the background color of the

10
Control Structure IF
  • IF / ELSE

11
Control Structure Loops
12
Control Structure include
  • include(path to file)
  • Sources in external text file
  • If you specify a file with PHP code, it will be
    executed
  • If file is not found, script continues with a
    warning
  • require(path to file)
  • If file is not found, script fails

13
Control Structure include
  • Uses
  • Place a common header/footer/navigation file on
    every page in your site
  • Reference common code or functions from every
    page in your site
  • Require an authorization script (written in PHP)
    on every page you want to secure

14
Functions
15
String Functions
complete list of string functions
http//us3.php.net/manual/en/ref.strings.php
16
Date Functions
  • time()
  • Returns the current time (on the server)
  • Date is represented as Unix Epoch (seconds since
    1/1/1970)
  • mktime(hour, minute, second, month, day, year)
  • Creates PHP date object

17
Date Functions
  • date(format, timestamp)
  • Formats date output
  • Format rules http//us3.php.net/manual/en/functio
    n.date.php

18
Error Checking
  • Turn off error reporting
  • error_reporting(0)
  • Turn on error reporting
  • Error_reporting(E_ALL)

19
In Class Work
  • Youve got a website
  • You want to check the current time and deliver a
    different look based on the time of day
  • Use date() and include() to check the time and
    deliver day.css and night.css to a mock home page.

20
HTML Forms
  • New to HTML Forms?
  • http//www.w3schools.com/html/html_forms.asp
Write a Comment
User Comments (0)
About PowerShow.com