PHP工厂模式的日常使用

(编辑:jimmy 日期: 2024/10/4 浏览:2)

负责生成其他对象的类或方法,这就是工厂模式,下面是一个经常见到的用法

<"x-b";
$test->$name=2;
 
var_dump($test);
 
 
//$test->x-b;//直接使用上面的属性,会被认为是一个减号
/*
报错:
PHP Notice: Use of undefined constant b - assumed 'b' in D:\phpServer\WWW\testtest.php on line 11
 
Notice: Use of undefined constant b - assumed 'b' in D:\phpServer\WWW\test\test.
php on line 11
 
*/
 
echo $test->{'x-b'}; //这种属性里面有-的这样包一下

以上所述是小编给大家介绍的PHP工厂模式的日常使用详解整合,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!