0% found this document useful (0 votes)
12 views

PHP2

Uploaded by

kamal.smail
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

PHP2

Uploaded by

kamal.smail
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

More PHP

Lecture 13
CGS 3066 Fall 2016

December 1, 2016
Multi Dimensional Arrays

► A multidimensional array is an array containing one or


more arrays.
► PHP understands multidimensional arrays that are two,
three, four, five, or more levels deep.
► However, arrays more than three levels deep are hard
to manage for most people.
► An n-dimensional array needs n indices to access an
element.
Date and Time

► The PHP date() function formats a timestamp to a


more readable date and time.
► Syntax: date(format,timestamp);
► The required format parameter of the date() function
specifies how to format the date (or time).
Here are some characters that are commonly used for dates:
► d - Represents the day of the month (01 to 31)
► m - Represents a month (01 to 12)
► Y - Represents a year (in four digits)
► l (lowercase ’L’) - Represents the day of the week
Creating a Date

► There are a few different ways to create a date.


► The mktime() function returns the Unix timestamp for a
date.
► The Unix timestamp contains the number of seconds
between the Unix Epoch (January 1 1970 00:00:00 GMT)
and the time specified.
► The PHP strtotime() function is used to convert a
human readable string to a Unix time.
Cookies

► A cookie is often used to identify a user.


► A cookie is a small file that the server embeds on the
user’s computer.
► Each time the same computer requests a page with a
browser, it will send the cookie too.
► With PHP, you can both create and retrieve cookie values.
Creating/Retrieving Cookies

► A cookie is created with the setcookie() function.


► Syntax: setcookie(name, value, expire, path, domain,
secure, httponly);
► Only the name parameter is required. All other parameters
are optional.
► The setcookie() function must appear BEFORE the
<html>tag.
► We can then retrieve the value of the cookie using the
global variable $ COOKIE.
► We can also use the isset() function to find out if the
cookie is set.
Modifying/ Deleting
Cookies

► The value of the cookie is automatically URLencoded when


sending the cookie, and automatically decoded when
received (to prevent URLencoding, use setrawcookie()
instead).
► To modify a cookie, just set (again) the cookie using
the setcookie() function.
► To delete a cookie, use the setcookie() function with
an expiration date in the past.
AJAX

► AJAX = Asynchronous JavaScript and XML.


► AJAX is a technique for creating fast and dynamic web
pages.
► AJAX allows web pages to be updated asynchronously by
exchanging small amounts of data with the server behind
the scenes. This means that it is possible to update parts of
a web page, without reloading the whole page.
► Classic web pages, (which do not use AJAX) must reload
the entire page if the content should change.
► Examples of applications using AJAX: Google Maps,
Gmail, Youtube, and Facebook tabs.

You might also like