Part 1: answer one of the following topics
1. How to define and call a PHP function? Show us with examples. (This topic is limited to 4 initial posts.)
2. When defining and using PHP classes, what part impressed you?
3. How to iterate a PHP numeric array and a PHP associative array? Show us with examples. Try different approaches.
4. Explore one of the PHP pre-defined array functions or string functions and let us know your findings. Show us with examples.
5. In PHP, how to make a copy of a class object? Show us with examples. (This topic is limited to 2 initial posts.)
6. Tell us something you learned in this module that you think are very useful.
Part 2: Reply to the following posts.
1.
How to define and call a PHP function?
COLLAPSE
A function name must start with a letter or an underscore. Function names are NOT case-sensitive.
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 "Hello world!". To call the function, just write its name followed by brackets ():
functionwriteMsg() {
echo"Hello world!";
}
writeMsg();// call the function
?>
2.
Defining and Calling a PHP Function
COLLAPSE
Functions are a critical part of having your programs be modular in nature,that is,in pieces that can be re-used and upgraded seamlessly.They save you countless minutes (and even hours) as they allow you to reuse code and not have to write sections all over again throughout your program.They require less typing, helpyou in avoiding syntax and logic errors versus inlinecode, increase speed (as functions only have to be compiled once irrespective of the number of times the function is called) and are very versatile.
To use a function, you must call it by name. PHP'sdatefunction is an example of a function, and is called as follows:
echo date("1");
Defining your own function is done as follows:
function
function_name([
parameter
[, ...]])
{
/ / code goes here
}
wherefunction_nameis the name that you give the function andparameteris an optional parameter, that you, the programmer, decide on.