PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

What is a function?


The concept of functions is something that a beginning programmer may be wary of or think of suspiciously, but in fact they will become more and more useful the more you program.

A function is just a container for a block of code. Functions are powerful because they enable you to create a section of code that can, if well-written, be copied and pasted from program to program saving you writing it each time.

In addition it makes debugging easier as you can track problems to individual blocks of code - the functions.

And also very attractive is that with a function you don't necessarily need to know how it works once written to use it - just like all the built-in functions in PHP, you can make it available to others and they can copy and paste it and it should work.

Here is a simple function in action:
<?php

function myfirstfunction() {
echo 
"My first function!";
}
myfirstfunction(); // call the function
?>



ASK A QUESTION

More functions PHP Questions

Is there a way to use readfile() and not have it display the byte number at the bottom?

PHP Fatal error does not result in HTTP error code 500. When PHP code throws a Fatal error, I would expect Apache to respond with HTTP 500, not a 200?

how can we display a particular data from database by creating a function

How can I call online a PHP function. It works local but when I put it online it does nothing. I call online a php function to load pictures into my flex application. Thanks Bart

How do I return a value from a function?



Custom Search