Advanced PHP Tutorial - PHP Programming - Lecture Slides, Slides of Programming Languages

A tutorial on advanced PHP language. Some functions included in this lecture are PHP Date, PHP Include, PHP File, PHP File Upload, PHP Cookies and PHP Sessions.

Typology: Slides

2012/2013

Uploaded on 12/17/2013

atifarifasif
atifarifasif 🇵🇰

4.2

(14)

39 documents

1 / 86

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PHP Tutorial
Advanced PHP
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56

Partial preview of the text

Download Advanced PHP Tutorial - PHP Programming - Lecture Slides and more Slides Programming Languages in PDF only on Docsity!

PHP Tutorial

Advanced PHP

PHP Advanced

  • PHP Date
  • PHP Include
  • PHP File
  • PHP File Upload
  • PHP Cookies
  • PHP Sessions

PHP Date() Function

( 1 st Chapter – PHP Date)

The PHP date() function is used to format a time and/or date.

  • The PHP date() function formats a timestamp to a more readable date and time.
  • A timestamp is a sequence of characters, denoting the date and/or time at which a certain event occurred.

PHP Date() Function (cont.)

( 1 st Chapter – PHP Date)

  • Syntax date( format , timestamp ) Parameter Description Required. Specifies the format of the timestamp format Optional. Specifies a timestamp. Default is the current date and time timestamp

Format the Date (cont.)

( 1 st Chapter – PHP Date)

  • Other characters, like"/", ".", or "-" can also be inserted between the letters to add additional formatting: "; echo date("Y.m.d"). ""; echo date("Y-m-d") ?>

Format the Date (cont.)

( 1 st Chapter – PHP Date)

  • The output of the code above could be something like this: 2009/05/ 2009.05. 2009 - 05 - 11

Adding a Timestamp (cont.)

( 1 st Chapter – PHP Date)

  • Syntax for mktime()
  • mktime(hour,minute,second,month,day,year,is_dst) To go

one day in the future we simply add one to the day

argument of mktime():

php

$tomorrow =

mktime(0,0,0,date("m"),date("d")+ 1 ,date("Y"));

echo "Tomorrow is ".date("Y/m/d", $tomorrow);

  • The output of the code above could be something like this:

Tomorrow is 2009 / 05 / 12

PHP Include File

  • Server Side Includes (SSI)
  • PHP include() Function
  • PHP require() Function

Server Side Includes (SSI) (cont.)

( 2 nd Chapter – PHP Include File)

  • These two functions are used to create functions, headers, footers, or elements that will be reused on multiple pages.
  • Server side includes saves a lot of work. This means that you can create a standard header, footer, or menu file for all your web pages. When the header needs to be updated, you can only update the include file, or when you add a new page to your site, you can simply change the menu file (instead of updating the links on all your web pages).

PHP include() Function ( 2 nd Chapter – PHP Include File)

  • The include() function takes all the content in a specified file and includes it in the current file.
  • If an error occurs, the include() function generates a warning, but the script will continue execution.

PHP include() Function (cont.)

( 2 nd Chapter – PHP Include File)

  • Example 2
    • Assume we have a standard menu file, called "menu.php", that should be used on all pages:

Home

About Us

Contact Us

PHP include() Function (cont.)

( 2 nd Chapter – PHP Include File)

  • All pages in the Web site should include this menu file. Here

is how it can be done:

Welcome to my home page.

Some text.

PHP require() Function ( 2 nd Chapter – PHP Include File)

  • The require() function is identical to include(), except that it handles errors differently.
  • If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop.

PHP require() Function (cont.)

( 2 nd Chapter – PHP Include File)

  • Error Example include() Function