可能重复:
如何访问此对象属性?
stdClass 对象 ( [show_title] => [link_titles] => [show_intro] => [show_category] => [link_category] => [show_parent_category] => [link_parent_category] => [show_author] => [link_author] => [show_create_date ] => [show_modify_date] => [show_publish_date] => [show_item_navigation] => [show_vote] => [show_icons] => [show_print_icon] => [show_email_icon] => [show_hits] => [show_noauth] => [urls_position ] => [menu-anchor_title] => [menu-anchor_css] => [menu_image] => [menu_text] => 1 [page_title] => [show_page_heading] => 0 [page_heading] => [pageclass_sfx] => [ menu-meta_description] => [menu-meta_keywords] => [robots] => [secure] => 0)
这是使用 print_r 进行 json-decode 后项目的输出我想访问属性 menu-anchor_css 但我不能做这样的事情
$items=json_decode($item->params);
$class = $items->menu-anchor_css ? 'class="'.$items->anchor_css.'" ' : '';
$title = $items->menu-anchor_title ? 'title="'.$items->anchor_title.'" ' : '';
因为它总是向我显示menu
未定义的错误消息。(连字符和下划线在这里似乎有问题)
十分感谢