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...

1 answer below »

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 FunctionCOLLAPSE



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.

Answered Same DayFeb 14, 2021BCS350

Answer To: Part 1: answer one of the following topics 1. How to define and call a PHP function? Show us with...

Neha answered on Feb 15 2021
155 Votes
Copy of a class object in PHP
In PHP, we use a keyword called clone to create a copy of an existing object. But a
method declared in object’s_clone can’t be called directly. For the cloning in PHP, it creates a shallow copy of all the properties present in object. Any property which is a reference in object will remain as the reference in the object’s_clone.
Syntax:
$copy_object_name = clone $object_to_be_copied
Example:
class TextClone {
    public $data1;
    public $data2;
    public $data3;
}

$obj = new TextClone ();

$copy = clone $obj;
$obj->data1 = "Cloning";
$obj->data2 = "In";
$obj->data3 = "PHP";

$copy->data1 = "Object ";
$copy->data2 = "Clone ";
$copy->data3 = "Learning";
echo "$obj->data1$obj->data2$obj->data3\n";

echo "$copy->data1$copy->data2$copy->data3\n";
?>
Reply to the posts
1) How to define and call a PHP function?
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....
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here