dousuo8400 2015-02-04 20:35
浏览 68

PHP:变量很大没有意义

I'm working on a Symfony 2 app. I've an object manage with Doctrine which it has private $beginDate which is a \DateTime.

I've a function very important :

public function isBefore($timestamp)
{
    print_r($this->beginDate);
    echo "<br />";
    $date = $this->beginDate->format("Y-m-d"); // (line 44)
    echo $date;
    echo "<br />";
    return $this->beginDate->getTimestamp() < $timestamp;
}

The first print_r display : DateTime Object ( [date] => 2015-01-01 00:00:00 [timezone_type] => 3 [timezone] => Europe/Paris )

The beginDate->format give me : Error: Call to a member function format() on a non-object in /var/.../GS/AcmeBundle/Entity/ARecur.php line 44

echo $date display : 2015-01-01

And $this->beginDate->getTimestamp() said nothing because the line 44 is blocking others errors (but without the line 44, i've the same error on this line !)

My PHP version :

PHP 5.4.4-14+deb7u14 (cli) (built: Aug 21 2014 08:36:44) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

Any ideas (Sorry for my bad english) Have a good day :)

  • 写回答

2条回答 默认 最新

  • dongxixiu9134 2015-02-04 20:46
    关注

    Remove the echo "<br />" and try, it is not good the mix you html in you code.

    评论

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算