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, 2255🔥, 0💬
Popular Posts:
How to login to the Developer Portal internally by you as the publisher? Normally, the Developer Por...
How to add a new operation to an API on the Publisher Dashboard of an Azure API Management Service? ...
How To Remove Slashes on Submitted Input Values in PHP? By default, when input values are submitted ...
How to add an API to an API product for internal testing on the Publisher Portal of an Azure API Man...
How to install .NET Framework in Visual Studio Community 2017? I have the Visual Studio Installer in...