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 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制