Tuesday, November 9, 2010

Summary of PHP commands (2)



The PHP Date() Function

date(format,timestamp)
  • d - Represents the day of the month (01 to 31)
  • m - Represents a month (01 to 12)
  • Y - Represents a year (in four digits)
echo date("Y-m-d")
produces:  2010-11-09

PHP include() and require Function

The two functions are identical in every way, except how they handle errors:
  • include() generates a warning, but the script will continue execution
  • require() generates a fatal error, and the script will stop
These two functions are used to create functions, headers, footers, or elements that will be reused on multiple pages.

PHP file handling:

The fopen() function is used to open files in PHP.

fopen("filenane","option");
option can be  r, r+, w,w+,a,a+,x, x+

PHP file upload:

Detail can be found:

http://www.w3schools.com/php/php_file_upload.asp

PHP cookie:

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. Function:

setcookie(name, value, expire, path, domain);

Detail can be found:
http://www.w3schools.com/php/php_cookies.asp 


PHP Session:

A PHP session variable is used to store information about, or change settings for a user session. Session 
variables hold information about one single user, and are available to all pages in one application.

The session_start() function must appear BEFORE the <html> tag:
session_destroy() will reset your session and you will lose all your stored session data.
Detail can be found:
 http://www.w3schools.com/php/php_sessions.asp


PHP Send mail:

mail(to,subject,message,headers,parameters)
Detail can be found:
http://www.w3schools.com/php/php_mail.asp 
http://www.w3schools.com/php/php_secure_mail.asp 

PHP Error Handling

  • Simple "die()" statements
  • Custom errors and error triggers
  • Error reporting

PHP Exception Handling

With PHP 5 came a new object oriented way of dealing with errors
Exception handling is used to change the normal flow of the code execution if a specified error (exceptional) condition occurs. This condition is called an exception.

PHP Filter

A PHP filter is used to validate and filter data coming from insecure sources.

Detail can be found:

http://www.w3schools.com/php/php_filter.asp 


 


No comments:

Post a Comment