dongtao9095 2013-10-05 21:06
浏览 51

无法访问对象中的任何元素

I have an object( $videopost ) where I am not able to gte values form key with a score in the name.

I fetch my values that way:

$videopost->titel

What works fine.

this returns nothing:

 $videopost->vorschaubild-klein

But should return string(77) "http://www.neuwagen.de/images/screenshots/20130828_mercedes_cla_45_amg_nw.jpg"

Why? Is the score in the key name the error? How can I fix it?

this is my object

object(SimpleXMLElement)#4330 (18) {
  ["id"]=>
  string(3) "995"
  ["titel"]=>
  string(19) "Mercedes CLA 45 AMG"
  ["beschreibung"]=>
  string(217) "Mercedes hat sich selbst eine Verjüngungskur verschrieben. Nicht nur das Make-Over der neuen der A-Klasse, sondern auch der völlig neu entwickelte CLA sollen jüngere Kunden zur Marke bringen. Große Motoren locken."
  ["vorschaubild-klein"]=>
  string(77) "http://www.neuwagen.de/images/screenshots/20130828_mercedes_cla_45_amg_nw.jpg"
  ["vorschaubild-gross"]=>
  string(81) "http://www.neuwagen.de/images/screenshots_big/20130828_mercedes_cla_45_amg_nw.jpg"
  ["kategorie"]=>
  string(17) "Auto-Fahrberichte"
  ["modell"]=>
  string(3) "CLA"
  ["hersteller"]=>
  string(13) "Mercedes-Benz"
  ["datum"]=>
  string(19) "2013-10-04 14:40:11"
  ["geaendert"]=>
  string(19) "2013-10-04 12:44:17"
  ["dateiname"]=>
  string(35) "20130828_mercedes_cla_45_amg_nw.flv"
  ["hd-dateiname"]=>
  string(35) "20130828_mercedes_cla_45_amg_nw.f4v"
  ["mp4"]=>
  string(80) "http://cdn.connetv.de/cdn/auto-de/mp4/20130828_mercedes_cla_45_amg_nw_archiv.mp4"
  ["ipad"]=>
  string(79) "http://cdn.connetv.de/cdn/auto-de/ipad/20130828_mercedes_cla_45_amg_nw_ipad.m4v"
  ["iphone"]=>
  string(83) "http://cdn.connetv.de/cdn/auto-de/iphone/20130828_mercedes_cla_45_amg_nw_iphone.m4v"
  ["tags"]=>
  string(27) "mercedes-benz,cla,limousine"
  ["video-laenge"]=>
  string(1) "0"
  ["base_url"]=>
  string(41) "http://cdn.connetv.de/cdn/auto-de/archiv/"
}
  • 写回答

1条回答 默认 最新

  • duang5049 2013-10-05 21:08
    关注

    The problem is that the - sign is treated as a substraction: $videopost->vorschaubild minus klein is actually evaluated. What is basically equivalent to NULL - "klein".

    To access it, use $videopost->{'vorschaubild-klein'}.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。