note 126570 added to functions.arguments
| From: | tesdy14 at gmail dot com | Date: | Mon, 08 Nov 2021 17:43:33 +0000 |
| Subject: | note 126570 added to functions.arguments | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217161@lists.php.net to get a copy of this message | ||
function my_fonction(string $value) {
echo $value . PHP_EOL;
}
my_fonction(['foo' => 'ko', 'bar' => 'not',
'goodValue' => 'Oh Yeah']['goodValue']);
// return 'Oh Yeah'
// This may sound strange, anyway it's very useful in a foreach (or other conditional
structure).
$expectedStatusCodes = [404, 403];
function getValueFromArray(string $value): string
{
return $value . PHP_EOL;
}
foreach ($expectedStatusCodes as $code) {
echo $currentUserReference = getValueFromArray(
[
404 => "Doesn't exist",
403 => 'Forbidden',
200 => "you're welcome"
][$code]
);
}
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 176.189.95.39)
----
Manual Page -- https://php.net/manual/en/functions.arguments.php
Edit -- https://main.php.net/note/edit/126570
Del: integrated -- https://main.php.net/note/delete/126570/integrated
Del: useless -- https://main.php.net/note/delete/126570/useless
Del: bad code -- https://main.php.net/note/delete/126570/bad+code
Del: spam -- https://main.php.net/note/delete/126570/spam
Del: non-english -- https://main.php.net/note/delete/126570/non-english
Del: in docs -- https://main.php.net/note/delete/126570/in+docs
Del: other reasons-- https://main.php.net/note/delete/126570
Reject -- https://main.php.net/note/reject/126570
Search -- https://main.php.net/manage/user-notes.php