PHP is a scripting language that allows web developers to create effective and interactive web pages that deal with databases. It acts as a competitive alternative to Microsoft ASP. 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 as HTML. PHP can perform a variety of diverse functions, such as collecting form data, updating the data in a database, creating and updating files on the server, as well as controlling user access. It is able to run on most operating systems and servers, making it highly compatible.
PHP has more than a thousand inbuilt functions and enables its developers to create their own functions as well. Functions are considered one of the extraordinary strengths of PHP.
Functions are basically a structure of code that can be used repetitively. Functions need to be called in order to achieve their specific task.
Creating a function callEducative()
which prints “Welcome to Educative!”
<?phpfunction callEducative() {echo "Welcome to Educative!";}callEducative(); // function call?>
clear()
function?It is an inbuilt function that clears the set by removing all of its values.
void public Ds\Set::clear( void )
The following example shows clear()
function in action.
<?php$set = new \Ds\Set([50, 40, 30, 20, 10]);// Display before clearingprint_r($set);$set->clear();// Display after clearingprint_r($set);?>
clear()
is calledDs\Set Object
[0] => 50
[1] => 40
[2] => 30
[3] => 20
[4] => 10
clear()
is calledDs\Set Object
No display as the set has no elements after the
clear()
function is applied.