【问题标题】:What's the difference in new stdClass() and new stdClass? [duplicate]new stdClass() 和 new stdClass 有什么区别? [复制]
【发布时间】:2013-03-10 11:34:47
【问题描述】:

我正在学习 php 的高级概念。 new stdClass 是做什么的?我知道new stdClass(); 做了什么。

例如)<?php new stdClass(); ? > 创建一个新对象。 <?php new stdClass; ? > 做同样的事情吗?注意没有括号。这有什么区别吗?我找不到 php 手册的相关文档。

【问题讨论】:

  • 谢谢:)。我找不到php手册在哪里说创建不带括号的对象?

标签: php


【解决方案1】:

没有区别。如果您没有将参数传递给构造函数,PHP 允许您省略括号。

【讨论】:

  • $a=new stdClass();var_dump($a); 显示object(stdClass)#1 (0) { }$a= new stdClass;var_dump($a); 显示object(stdClass)#2 (0) { }。为什么会有差异?
猜你喜欢
  • 2012-12-29
  • 2018-08-02
  • 2011-11-22
  • 2014-02-10
  • 2012-04-14
  • 1970-01-01
  • 2019-12-03
  • 1970-01-01
相关资源
最近更新 更多