You are advised to check corresponding YouTube video at the end of this article.
<?php
function one_ping($host = "google.com") {
echo "<pre>";
system ("ping ". $host);
echo "</pre>";
}
one_ping("yahoo.com");
?>
The function "one_ping" has a default argument of "google.com" assigned to the parameter $host. This means that if an argument is not passed when the function is called, it will use "google.com" as the default value for the $host parameter.
Using default arguments in functions can be useful in situations where you want to provide a default value for a parameter, but still allow the user to override it if needed. This can make the function more flexible and easier to use.
No comments:
Post a Comment