Able to see a variable in print_r()'s output,

2018-12-31 04:59发布

I googled, installed Devel, Drupal for Firebug, but I can't find it.

I found what I want, I know where it is; I just don't know how to get it.

I'll put this in code brackets, but Devel tells me the file name (which I want to stick into the .tpl.php file) is here:

field_image (Object) stdClass 
  handler (Object) views_handler_field_field 
    view (Object) view 
      result (Array, 2 elements) 
        0 (Object) stdClass 
          _field_data (Array, 1 element) 
            nid (Array, 2 elements) 
              entity (Object) stdClass
                field_image (Array, 1 element) 
                  und (Array, 1 element)
                    0 (Array, 11 elements)                                      
                      filename (String, 23 characters ) FILENAME.jpg

So, how do I get that FILENAME.jpg to be output using PHP?

<?php print $something->other; ?>

9条回答
流年柔荑漫光年
2楼-- · 2018-12-31 05:23

Try:

$field_image->handler->view->result[0]->_field_data['nid']['entity']->field_image['und'][0]['filename']
查看更多
谁念西风独自凉
3楼-- · 2018-12-31 05:23

If you have devel installed and try

krumo ($variable);

Just bear in mind as default only admin users have rights to use the krumo command, but this can be sorted out by looking at the DEVEL role permissions. (don't forget to remove these permissions once your done though)

查看更多
姐姐魅力值爆表
4楼-- · 2018-12-31 05:23

Let me summarize up

print_r($data); => Traditional view of printing array.

var_dump($data); => Not so much cleaned view , gives you everything but in very suffocated manner

print "<pre>"; print_r($data); => A cleaned view but will not get   data types information.

dpm($data); => It gives you everything, but you need to have installed devel.
查看更多
登录 后发表回答