Is it possible to use an array without initializing it?

前端 未结 2 1468
深忆病人
深忆病人 2021-01-25 23:41

I have seen some code from Stack Overflow. It confused me a lot. I just don\'t know whether some part is missing or not.

The code is as follows:

$ch = cu         


        
相关标签:
2条回答
  • 2021-01-26 00:03

    When a value is first assigned to $out2, it is initialized as whatever datatype in needs to be. In this case, an array.

    0 讨论(0)
  • 2021-01-26 00:09

    In short, yes.

    PHP isn't (at the moment) that explicit about declaring data types when creating variables - unlike other languages, although I'm sure PHP are changing their ways.

    Although you can do this, it's advised (good practice) to declare the data type of the variable before assigning value(s) to it.

    0 讨论(0)
提交回复
热议问题