What is a function?
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
?>
Comment on this Question and Answer >>>
ASK A QUESTION
More functions PHP Questions
1-what is a header("Location:http//www.website.com"); 2-how does it work? 3-What is a reason to use this function?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?
Hey, I need a php script to copy a complete directory to a new one (which is a variable). i.e www.webpage.com/example/ --> www.webpage.com/folder_just_created/. I've looked for hours Kurt
Can we use include ("abc.php") two times in PHP page "makeit.php" ?
difference between fetch_array function & fetch_row function
