Can you throw an array instead of a string as an exception in php?

后端 未结 4 1314
说谎
说谎 2021-02-07 00:22

I want to throw an array as an exception in php, instead of a string. Is it possible to do this if you define your own class that extends the Exception class?

For exampl

4条回答
  •  南旧
    南旧 (楼主)
    2021-02-07 01:08

    Yes, you can. You will need to extend the Exception class and create a __construct() method to do what you want.

提交回复
热议问题