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, ∼2469🔥, 0💬
Popular Posts:
How To Move Uploaded Files To Permanent Directory in PHP? PHP stores uploaded files in a temporary d...
How to build a test service operation to dump everything from the "context.Request" object in the re...
Where to get a JSON.stringify() Example Code in JavaScript? Here is a good JSON.stringify() example ...
How to use the "send-one-way-request" Policy statement to call an extra web service for an Azure API...
How to use the JSON to XML Conversion Tool at freeformatter.com? If you want to try the JSON to XML ...