donglie1994 2013-11-15 04:09
浏览 47
已采纳

Null有课吗?

Symfony 1.4 and Propel are involved but I'm not sure they cause strange behaviour described below.

$this->_parent = TestPeer::retrieveByPK($this->getParentId());
var_dump(get_class($this->_parent), $this->_parent);

prints out 'Test' and 'null'.

How can it be this way?

PS

1/ $this->getParentId() returns integer and there is no corresponding record in DB, so $this->_parent should be null.

2/ php 5.5.6, xdebug, opcache

  • 写回答

1条回答 默认 最新

  • dongzhao5834 2013-11-15 04:38
    关注

    Quote from The PHP Manual for get_class:

    5.3.0 NULL became the default value for object, so passing NULL to object now has the same result as not passing any value.

    Which together with:

    Returns the name of the class of which object is an instance. Returns FALSE if object is not an object.

    If object is omitted when inside a class, the name of that class is returned.

    ...means that when passing null, you get the name of the class containing the call.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 下载honeyd时报错 configure: error: you need to instal a more recent version of libdnet
  • ¥15 距离软磁铁一定距离的磁感应强度大小怎么求
  • ¥15 霍尔传感器hmc5883l的xyz轴输出和该点的磁感应强度大小的关系是什么
  • ¥15 vscode开发micropython,import模块出现异常
  • ¥20 Excel数据自动录入表单并提交
  • ¥30 silcavo仿真,30分钟,只需要代码
  • ¥15 FastReport 怎么实现打印后马上关闭打印预览窗口
  • ¥15 利用3支股票数据估计其均值和方差的95%置信区间。
  • ¥15 微信小程序运行一项功能时,弹出未知错误弹框,检查代码没有问题
  • ¥15 ATAC测序生成self-pseudo replicates之前是否要进行去线粒体reads
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部