Category: php


Explanation of a Basic PHP Function

What is a PHP function?

In PHP a function represents a block of instructions that perform a task. A PHP Function allows the user to re-use blocks of script without having to rewrite all the code every time it's needed. This is useful for repetitive tasks that perform the same jobs over and over.

PHP has a large number of built-in functions. Thus it is always good to check or Google before writing a function. There may already be one that you can use saving you a lot of time.

Declaring functions

Functions can be placed anywhere in a php document. However, it will make for easy-to-read code if you place your functions at the top of the document or in a separate file.

If you declared your PHP functions in a separate file, the functions must be made available to the main script using one of the include functions such as:

"include_once()". These functions are typically placed at the top of the main php document.

PHP Function Syntax

PHP functions start with the word "function," followed by a name for the function - a name that you give it.

ie. function myfunction(){} Use function names that resemble function's purpose.
Next you use: "()"

followed by:
Code goes between the curly brackets

<h3>PHP Function - Example</h3>
function my_first_function()
code to do something;
Author: D.Shaun Morgan

how to upload images and files php Upload Images to Webserver HTML Form PHP Function # UPLOAD FILE function upload_file(){ echo '

how to turn variable value into variable name Variable Variables in PHP Every so often when you are writing a php file, we all run into a situation where we would like for the name of the string that is inside

what is php Explanation of PHP Basic Syntax --New to PHP Php is a language that is very much like writing c. The best feature of PHP versus c is that it is designed pri

notepad plus Notepad++ Download Notepad Plus Plus Notepad plus plus is an open source, free text editor. It is

php arrays php Passing arrays to another page Author: D.Shaun Morgan Versions and Skill Level PHP Version - PHP 5x Reader skill level


Leave a Comment


Name:      | Email:      | Website:



Enter The Above Security Code: