PHP is a scripting language that allows web developers to create practical and interactive web pages that deal with databases. It is an open-source scripting language that acts as a core part of WordPress and helps run one of the largest and most popular social networks, Facebook.
PHP code runs on the server, and the browser receives the output in the form of HTML. PHP can perform various functions. These functions include collecting form data, updating the data in a database, creating, updating files on the server, and controlling user access. It can run on most operating systems and servers, making it highly compatible.
PHP has more than a thousand built-in functions that enable its developers to create their own functions additionally. Functions are considered one of the extraordinary strengths of PHP.
Functions are a structure of code that can be used repetitively. Functions need to be called to achieve their specific task.
The code below shows how to create a function, callEducative(),
that prints Welcome to Educative!
:
<?phpfunction callEducative() {echo "Welcome to Educative!";}callEducative(); // function call?>
copy()
function?The Ds\Set copy()
function is a built-in function that will return a DS\Set
element’s copy. The copy()
function is mostly used to copy values from one DS\Set
object to another. It returns a shallow copy of a particular set.
The prototype of the copy()
method is shown below:
Ds\Set public Ds\Set::copy( void )
The following code shows the copy()
function in action:
<?php$set = new \Ds\Set(["Learn", "PHP", "from", "Educative"]);print_r($set);$a=$set->copy();print_r($a);?>
copy()
function is called[0] => Learn
[1] => PHP
[2] => From
[3] => Educative
copy()
function is called[0] => Learn
[1] => PHP
[2] => From
[3] => Educative