duanhuangyun3887 2019-05-27 14:45
浏览 193

为什么var_dump在访问具有数组值的键时显示NULL?

I'm trying to loop through the Wordpress themes I have installed to pull out a piece of data. I need to get access to $value->headers["TextDomain"] but when I try to access $value->headers I get a NULL response.

Here is the Wordpress Theme Object array that I am trying to pull data from:

object(WP_Theme)#795 (12) {
  ["update"]=>
  bool(false)
  ["theme_root":"WP_Theme":private]=>
  string(56) "/Users/tygoss/Projects/QuickPress/prod/wp-content/themes"
  ["headers":"WP_Theme":private]=>
  array(11) {
    ["Name"]=>
    string(10) "Black Jane"
    ["ThemeURI"]=>
    string(0) ""
    ["Description"]=>
    string(187) "Black Jane is a clean SuevaFree child theme with an optional slideshow on homepage, a new header layout in addition to the five header layouts available on SuevaFree and new Google Fonts."
    ["Author"]=>
    string(16) "ThemeinProgress."
    ["AuthorURI"]=>
    string(31) "https://www.themeinprogress.com"
    ["Version"]=>
    string(5) "1.0.4"
    ["Template"]=>
    string(9) "suevafree"
    ["Status"]=>
    string(0) ""
    ["Tags"]=>
    string(302) "blog, e-commerce, photography, custom-background, custom-colors, custom-header, custom-logo, custom-menu, featured-images, flexible-header, footer-widgets, post-formats, right-sidebar, sticky-post, theme-options, threaded-comments, translation-ready, one-column, two-columns, three-columns, grid-layout"
    ["TextDomain"]=>
    string(10) "black-jane"
    ["DomainPath"]=>
    string(10) "/languages"
  }
  ["name_translated":"WP_Theme":private]=>
  NULL
  ["errors":"WP_Theme":private]=>
  NULL
  ["stylesheet":"WP_Theme":private]=>
  string(10) "black-jane"
  ["template":"WP_Theme":private]=>
  string(9) "suevafree"
}

If I var_dump( $value->stylesheet ) I get string(10) "black-jane"

But if I var_dump ( $value->headers ) I get NULL

Here is my loop:

    $all_themes = wp_get_themes();
    foreach ($all_themes as $key => $value) {
      echo '<pre>';
      var_dump($value->headers);
      echo '</pre>';
    }

Shouldn't $value->headers dump out an array of 11 items? Why is it returning NULL and why does $value->stylesheet work but not $value-headers?

  • 写回答

1条回答 默认 最新

  • dongmeirang4679 2019-05-27 23:50
    关注

    $value->get("the thing from the header array") works flawlessly!

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器