Declare an object in PHP using constant to hold class name (like you can do with variables)?

前端 未结 2 540
时光说笑
时光说笑 2021-01-27 16:48

This question about syntax/syntax capabilities in PHP. Take for example, using variables to store class names when declaring objects:

$className= \'myClass\';
$         


        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-27 17:25

    As class name (e.g. MyClass) can not be distinguished from constant name MyClass - your approach will not work.

提交回复
热议问题