Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我对此进行了搜索,但找不到我的问题的答案。
当一个变量被声明时没有值,像这样:
$var; public $aVar;
变量的值是未知的,就像在许多语言中一样(即之前在内存中的任何内容),还是默认设置为变量null?
null
默认情况下,声明没有值的变量和未定义/未声明的变量null。
但是,仅做$var;不会声明变量,因此您只能在对象中声明没有值的变量。
$var;
演示:
<?php class Test { public $var; } $var; $t = new Test(); var_dump($var); var_dump($t->var);
输出:
Notice: Undefined variable: var in - on line 5 NULL NULL
I 'm trying to build a DI container and I 've stumbled on to the following problem: I have a method that retrieves a list of registered instances for a given type and I want to use that to inject I
I