Why declare PHP variable type in a comment?

前端 未结 5 2077
[愿得一人]
[愿得一人] 2021-02-02 09:51

I\'m fairly new to PHP, and I just started using NetBeans to develop my PHP code.

Out of the blue, as I entered a variable in a query, a dialog popped up and asked me to

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-02 10:38

    Because PHP is a loose/duck typed language, when you create a large program those type hints can help you or others understand what is going on if an issue should arise. For example, expecting a mixed type and sending an integer.

提交回复
热议问题