G
G
grabbee2020-04-16 21:32:58
PHP
grabbee, 2020-04-16 21:32:58

Is it possible to specify multiple types for a function parameter in PHP?

You can specify the type of a variable for a class method.
If I can send a "string", an empty string or nothing (NULL) to my method - how can I specify this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-04-16
@grabbee

As always, there is one thing in the title, something completely different in the text
"an empty string" is not a type.
That is, the task is reduced to a string or null
, that is, it’s trite? string
Several types can be set in PHP8, through a wand

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question