Wednesday, February 22, 2012

Exception Handling

August 10, 2010 by tutorials · Leave a Comment 

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.
This is what normally happens when an exception is triggered:

The current code state is saved
The code execution will switch to a predefined (custom) exception handler function
Depending on [...]

Error handling

August 10, 2010 by tutorials · Leave a Comment 

The default error handling in PHP is very simple. An error message with filename, line number and a message describing the error is sent to the browser.
Error handling:
When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional [...]

Sending Emails

August 10, 2010 by tutorials · Leave a Comment 

PHP allows you to send e-mails directly from a script.
The PHP mail() function:
The PHP mail() function is used to send emails from inside a script.
Syntax:
mail(to,subject,message,headers,parameters)
Attributes:
to – Required. Specifies the receiver / receivers of the email
subject – Required. Specifies the subject of the email. 
message – Required. Defines the message to be sent. Each line [...]

Sessions

August 10, 2010 by tutorials · Leave a Comment 

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.
Session Variables:
When you are working with an application, you open it, do some changes and then you close it. [...]

Cookies

August 10, 2010 by tutorials · Leave a Comment 

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 a Cookie:
The [...]

File Upload

August 10, 2010 by tutorials · Leave a Comment 

With PHP, it is possible to upload files to the server.
Create an Upload-File Form:
To allow users to upload files from a form can be very useful.
Look at the following HTML form for uploading files:
<html>
<body>
<form action=”upload_file.php” method=”post”
enctype=”multipart/form-data”>
<label for=”file”>Filename:</label>
<input type=”file” name=”file” id=”file” />
<br />
<input type=”submit” name=”submit” value=”Submit” />
</form>
</body>
</html>
Notice the following about the HTML form above:

The enctype attribute [...]

File Handling

August 10, 2010 by tutorials · Leave a Comment 

The fopen() function is used to open files in PHP.
Opening a File:
The fopen() function is used to open files in PHP.
The first parameter of this function contains the name of the file to be opened and the second parameter specifies in which mode the file should be opened:
<html>
<body>
<?php
$file=fopen(“welcome.txt”,”r”);
?>
</body>
</html>
The file may be opened in one [...]

PHP Include File

August 9, 2010 by tutorials · Leave a Comment 

You can insert the content of one PHP file into another PHP file before the server executes it, with the include() or require() function.

PHP Date() Function

August 9, 2010 by tutorials · Leave a Comment 

The PHP date() function is used to format a time and/or date. It formats a timestamp to a more readable date and time.

PHP Forms

August 9, 2010 by tutorials · Leave a Comment 

The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.

Next Page »