无法在PHP

问题描述:

<?php 
$picid= $_GET['id']; 
intval($picid); 
$file="data.xml"; 
echo $picid; //output is 121 (say) 
$data= new SimpleXMLElement($file, null, true); 
$data->score[$picid]=$data->score[$picid]+3; 
file_put_contents($file, $data->asXML()); 
?> 

中的XML文件的变化来编辑XML文件的内容,以无法在PHP

<score 121="3">0</score> 

所述分数[0]标签。

而我要上得分[121]标记输出

<score>3</score> 

但是,当我在我的代码更改

<?php 
$picid= $_GET['id']; 
intval($picid); 
$file="data.xml"; 
echo $picid; //121 is printed (say) 
$data= new SimpleXMLElement($file, null, true); 
$data->score[121]=$data->score[121]+3; 
echo $data->score[121]; 
file_put_contents($file, $data->asXML()); 
?> 

我正在gettng所需的输出。为什么?

你的intval返回void。

尝试:

$picid = intval($picid); 
+0

哦,亲爱的,这样一个愚蠢的错误,。谢谢,它工作。 :) – 2013-02-26 23:19:02

+0

不客气) – apoq 2013-02-26 23:37:35