PHP user defined function

I will show you how to use user defined functions in PHP.

user defined functions are used mostly to decrease the coding load.

Besides the built-in PHP functions, we can create our own functions.

A function is a block of statements that can be used repeatedly in a program.

A function will not execute immediately when a page loads.

A function will be executed by a call to the function.

A user defined function declaration starts with the word “function”:

we create a function named “premal()”. The opening curly brace ( { ) indicates the beginning of the function code and the closing curly brace ( } ) indicates the end of the function. The function outputs “premal katigar!”. To call the function, just write its name:

user_defined_functions

We have done user defined functions.

How to fetch portion of website

file_get_contents function

file_get_contentsReads entire file into a string

Code

string file_get_contents ( string $filename [, bool $use_include_path = false [, resource$context [, int $offset = -1 [, int $maxlen ]]]] )

Description

This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specifiedoffset up to maxlen bytes. On failure, file_get_contents() will return FALSE.

file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.