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, ∼2662🔥, 0💬
Popular Posts:
What is test testing area for? The testing area is provided to allow visitors to post testing commen...
How to use the Atom Online Validator at w3.org? w3.org feed validation service is provided at http:/...
How to access URL template parameters from "context.Request.Matched Parameters"object in Azure API P...
How to add request URL Template Parameters to my Azure API operation 2017 version to make it more us...
How To Pad an Array with the Same Value Multiple Times in PHP? If you want to add the same value mul...