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, 1913🔥, 0💬
Popular Posts:
How to Build my "sleep" Docker image from the Alpine image? I want the container to sleep for 10 hou...
How to use "{{...}}" Liquid Codes in "set-body" Policy Statement? The "{{...}}" Liquid Codes in "set...
What validation keywords I can use in JSON Schema to specifically validate JSON Array values? The cu...
dev.FYIcenter.com is a Website for software developer looking for software development technologies,...
Can You Specify the "new line" Character in Single-Quoted Strings? You can not specify the "new line...