How can you specify a default value for a function argument in PHP?
- By using the = default syntax.
- By using the : syntax.
- By using the ? syntax.
- By using the ?? syntax.
In PHP, you can specify a default value for a function argument by using the ? syntax before the argument name. This allows the argument to have a default value of null if not provided.
Loading...
Related Quiz
- What is the difference between abstract classes and interfaces in PHP? When would you use each?
- You have a PHP script and you need to create an object from a class. How would you do this?
- You are writing a PHP script and you want to stop the execution of a loop once a certain condition is met. How would you do this using break?
- What are some of the uses of interfaces in PHP OOP?
- You are writing a PHP script and you need to define an abstract class. How would you do this?