PHP File Handling

PHP File Handling:-

PHP supports file handling with opening a file,closing a file,reading a file,writing a file etc. functions.This tutorial will let   you know about every mode of file handling. The table will introduce you with the various mode of file opening.

 

PHP supports this feature using the following functions:-

i)  fopen:-

To open a file in a particular mode, like r: read, w: write, a: append etc.

ii)  feof:-

To check whether the pointer has reached at the end of the file or not.

iii)  fclose:-

To close the file.

iv)  fgets:-

To extract the content line by line.

v)  fgetc:-

To extract the content character by character.

MODES     DESCRIPTION:-

r read only
r+ read and write
w write only, clears the previous content, creates the file if it does not exist
w+ read/write, clears the previous content,  creates the file it is not present
a append, open and write the content to the end of the file, creates if the file is not present
a+ append/write,  open and write the content to the end of the file, creates if the file is not present
x write only, returns an error message and false value if the file is present otherwise creates the new file
x+ read/write , returns an error message and false value if the file is present otherwise creates the new file

jQuery .dbclick() method

.dbclick():-

The double click event occurs when an element is double clicked.(clicking two time)

Syntax:-

$(selector).dbclick(function)

Description:-

$(selector) – to find the elements.
.dbclick – .dbclick event defining for action .
function – It’s optional a particular function to run when click event occur.

Example:-

<html>
<head>
<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”>
</script>
<script>
$(document).ready(function(){
$(“h1″).dblclick(function(){
alert(“The heading was double-clicked.”);
});
});
</script>
</head>
<body>
<h1>Double-click on Wamp6.</h1>
</body>
</html>

Output:-

The heading was clicked.

Important note:-

If you don’t want to download and host jQuery yourself, you can include it from a CDN (Content Delivery Network).
Both Google and Microsoft host jQuery.

CDN:-

<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”>

jQuery .click() method

.click():-

The click event occurs when an element is clicked.(clicking once time)

Syntax:-

$(selector).click(function)

Description:-

$(selector) – to find the elements.
.click – .click event defining for action .
function – It’s optional a particular function to run when click event occur.

Example:-

<html>
<head>
<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”>
</script>
<script>
$(document).ready(function(){
$(“h1″).click(function(){
alert(“The heading was clicked.”);
});
});
</script>
</head>
<body>
<h1>Welcome on Wamp6</h1>
</body>
</html>

Output:-

The heading was clicked.

Important note:-

If you don’t want to download and host jQuery yourself, you can include it from a CDN (Content Delivery Network).
Both Google and Microsoft host jQuery.

CDN:-

<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”>

jQuery change() method

.change():-

The change event works when the value of an element is changed.

Syntax:-

$(selector).change(function)

Description:-

$(selector) – to find the elements.
.change – .change method defining for action.
function – It’s optional a particular function to run when event occur.

Example:-

<html>
<head>
<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”>
</script>
<script>
$(document).ready(function(){
$(“input”).change(function(){
alert(“please enter the text input box.”);
});
});
</script>
</head>
<body>
<input type=”text” name=”Wamp6″>
<p>write here something then event occures showing alert massage</p>
</body>
</html>

Output:-

please enter the text input box.

Important note:-

If you don’t want to download and host jQuery yourself, you can include it from a CDN (Content Delivery Network).
Both Google and Microsoft host jQuery.

CDN:-

<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”>

jQuery blur() method

.blur():-

The blur events occur when an element direction wrong the focus.

Syntax:-

$(selector).blur(function)

Description:-

$(selector) - to find the elements.
.blur – .blur method defining for action.
function – It’s optional a particular function to run when event occur.

Example:-

<html>
<head>
<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”>
</script>
<script>
$(document).ready(function(){
$(“input”).blur(function(){
alert(“This input field has lost its focus.”);
});
});
</script>
</head>
<body>
Enter your name: <input type=”text”>
<p>write something in input box neither lose the focus blur events</p>
</body>
</html>

output:-

This input field has lost its focus.

important note:-

If you don’t want to download and host jQuery yourself, you can include it from a CDN (Content Delivery Network).
Both Google and Microsoft host jQuery.

 

CDN:-

<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”>