为什么这个输出是空白的?

发布于 2024-11-16 03:14:06 字数 3751 浏览 4 评论 0原文

我知道我一定做错了一些简单的事情。当我这样做时:

 echo '<pre>';
 print_r($event->when);
 echo '</pre>';

我得到这个:

 Array
(
[0] => Zend_Gdata_Extension_When Object
    (
        [_rootElement:protected] => when
        [_reminders:protected] => 
        [_startTime:protected] => 2011-06-16T10:00:00.000-05:00
        [_valueString:protected] => 
        [_endTime:protected] => 2011-06-17T11:00:00.000-05:00
        [_rootNamespace:protected] => gd
        [_rootNamespaceURI:protected] => 
        [_extensionElements:protected] => Array
            (
            )

        [_extensionAttributes:protected] => Array
            (
            )

        [_text:protected] => 
        [_namespaces:protected] => Array
            (
                [atom] => Array
                    (
                        [1] => Array
                            (
                                [0] => http://www.w3.org/2005/Atom
                            )

                    )

                [app] => Array
                    (
                        [1] => Array
                            (
                                [0] => http://purl.org/atom/app#
                            )

                        [2] => Array
                            (
                                [0] => http://www.w3.org/2007/app
                            )

                    )

                [gd] => Array
                    (
                        [1] => Array
                            (
                                [0] => http://schemas.google.com/g/2005
                            )

                    )

                [openSearch] => Array
                    (
                        [1] => Array
                            (
                                [0] => http://a9.com/-/spec/opensearchrss/1.0/
                            )

                        [2] => Array
                            (
                                [0] => http://a9.com/-/spec/opensearch/1.1/
                            )

                    )

                [rss] => Array
                    (
                        [1] => Array
                            (
                                [0] => http://blogs.law.harvard.edu/tech/rss
                            )

                    )

            )

    )

)

然后我试图通过这样做来获取 startTime

$StartTime = $event->when->startTime;

但我什么也没得到。

然而,当我这样做时:

 pr($event->published);

我得到这个:

Zend_Gdata_App_Extension_Published Object
(
[_rootElement:protected] => published
[_rootNamespace:protected] => atom
[_rootNamespaceURI:protected] => 
[_extensionElements:protected] => Array
    (
    )

[_extensionAttributes:protected] => Array
    (
    )

[_text:protected] => 2011-06-15T03:32:14.000Z
[_namespaces:protected] => Array
    (
        [atom] => Array
            (
                [1] => Array
                    (
                        [0] => http://www.w3.org/2005/Atom
                    )

            )

        [app] => Array
            (
                [1] => Array
                    (
                        [0] => http://purl.org/atom/app#
                    )

                [2] => Array
                    (
                        [0] => http://www.w3.org/2007/app
                    )

            )

    )

)

我可以这样做:

$dateAdded = $event->published->text;
echo $dateAdded;

并且我看到一个输出......

I know I must be doing something simple wrong. When I do this:

 echo '<pre>';
 print_r($event->when);
 echo '</pre>';

I get this:

 Array
(
[0] => Zend_Gdata_Extension_When Object
    (
        [_rootElement:protected] => when
        [_reminders:protected] => 
        [_startTime:protected] => 2011-06-16T10:00:00.000-05:00
        [_valueString:protected] => 
        [_endTime:protected] => 2011-06-17T11:00:00.000-05:00
        [_rootNamespace:protected] => gd
        [_rootNamespaceURI:protected] => 
        [_extensionElements:protected] => Array
            (
            )

        [_extensionAttributes:protected] => Array
            (
            )

        [_text:protected] => 
        [_namespaces:protected] => Array
            (
                [atom] => Array
                    (
                        [1] => Array
                            (
                                [0] => http://www.w3.org/2005/Atom
                            )

                    )

                [app] => Array
                    (
                        [1] => Array
                            (
                                [0] => http://purl.org/atom/app#
                            )

                        [2] => Array
                            (
                                [0] => http://www.w3.org/2007/app
                            )

                    )

                [gd] => Array
                    (
                        [1] => Array
                            (
                                [0] => http://schemas.google.com/g/2005
                            )

                    )

                [openSearch] => Array
                    (
                        [1] => Array
                            (
                                [0] => http://a9.com/-/spec/opensearchrss/1.0/
                            )

                        [2] => Array
                            (
                                [0] => http://a9.com/-/spec/opensearch/1.1/
                            )

                    )

                [rss] => Array
                    (
                        [1] => Array
                            (
                                [0] => http://blogs.law.harvard.edu/tech/rss
                            )

                    )

            )

    )

)

I'm then trying to get startTime by doing this:

$StartTime = $event->when->startTime;

But I'm not getting anything.

And yet, when I do this:

 pr($event->published);

I get this:

Zend_Gdata_App_Extension_Published Object
(
[_rootElement:protected] => published
[_rootNamespace:protected] => atom
[_rootNamespaceURI:protected] => 
[_extensionElements:protected] => Array
    (
    )

[_extensionAttributes:protected] => Array
    (
    )

[_text:protected] => 2011-06-15T03:32:14.000Z
[_namespaces:protected] => Array
    (
        [atom] => Array
            (
                [1] => Array
                    (
                        [0] => http://www.w3.org/2005/Atom
                    )

            )

        [app] => Array
            (
                [1] => Array
                    (
                        [0] => http://purl.org/atom/app#
                    )

                [2] => Array
                    (
                        [0] => http://www.w3.org/2007/app
                    )

            )

    )

)

and I can do this:

$dateAdded = $event->published->text;
echo $dateAdded;

and I see an output...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

美羊羊 2024-11-23 03:14:06

根据 官方 Zend_Gdata_Extension_When 文档,有一个名为 < code>getStartTime() 这会给你时间。

如果您执行 $event->when[0]->getStartTime()$event->when[0]->startTime,您将获取开始时间。

According to to the official Zend_Gdata_Extension_When documentation, there's a method called getStartTime() which will give you the time.

If you do $event->when[0]->getStartTime() or $event->when[0]->startTime, you'll get the start time.

掌心的温暖 2024-11-23 03:14:06

startTime 被标记为受保护。你不能像你一样从外部引用它。该对象中必须有一个 getter 函数“getStartTime()”,该函数允许您公开引用它。

编辑:它还返回一个对象数组 - 而不是单个对象,因此您需要像这样引用它: $event[0]->getterFunction() 或使用 a 循环遍历数组foreach 访问循环中的各个对象

startTime is marked protected. You can't reference it from outside like you did. There must be a getter function 'getStartTime()' function in that object that would allow you to reference it publicly.

EDIT: Also it is returning an object array - not an single object, so you would need to reference the it like: $event[0]->getterFunction() or loop through the array with a foreach accessing the individual objects in the loop

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文