Tools, FAQ, Tutorials:
Specifying Argument Default Values in PHP
How To Specify Argument Default Values? in PHP?
✍: FYIcenter.com
If you want to allow the caller to skip an argument when calling a function, you can define the argument with a default value when defining the function. Adding a default value to an argument can be done like this "function name($arg=expression){}. Here is a PHP script on how to specify default values to arguments:
<?php
function printKey($key="download") {
print("PHP $key\n");
}
printKey();
printKey("hosting");
print("\n");
?>
This script will print:
PHP download PHP hosting
⇒ Function with Undefined Number of Arguments in PHP
⇐ Returning a Reference from a Function in PHP
2016-12-04, ∼2793🔥, 0💬
Popular Posts:
How to Install Docker Desktop 2.5.0 on Windows 10? You can follow this tutorial to Install Docker De...
Why I am getting "LNK1104: cannot open file 'MSCOREE.lib'" error when building a C++/CLI program? Vi...
How To Loop through an Array without Using "foreach" in PHP? PHP offers the following functions to a...
How To Set session.gc_divisor Properly in PHP? As you know that session.gc_divisor is the frequency ...
Where to find tutorials on EPUB file format? I want to know how to create EPUB books. Here is a larg...