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, ∼2642🔥, 0💬
Popular Posts:
What Is session_register() in PHP? session_register() is old function that registers global variable...
What is EPUB 2.0 Metadata "dc:publisher" and "dc:rights" elements? EPUB 2.0 Metadata "dc:publisher" ...
Where to get a real Atom XML example? You can follow this tutorial to get a real Atom XML example: 1...
How To Access a Global Variable inside a Function? in PHP? By default, global variables are not acce...
Where to find tutorials on Microsoft Azure services? Here is a large collection of tutorials to answ...