当我尝试打开 chart.php 文件时出现服务器错误。我现在使用 php 5.3.3。但是,这个问题在 php5.4 中没有发生。我该如何解决这个问题?
在 php 日志文件中,有一个与 chart.php 相关的错误。
[Mon Nov 12 05:04:19 2012] [error] [client 85.108.15.253] PHP Parse error: syntax error, unexpected '[' in /var/www/vhosts/phisto.org/httpdocs/chart.php 在线249、参考:http ://www.phisto.org/browse.php
图表.php
include("head.php");
include("menu.php");
include("functions.php");
$deger = "";
$resultsarray2 = $_SESSION["RESULTSARRAY2"];
$rowcount = $_SESSION["ROWCOUNT"];
$deger = $_POST['GRAPH'];
// ROWCOUNT VE RESULTSARRAY2 GEREKLI !!!!!!!
class obje {
private $name;
private $subset;
private $degree;
private $index ;
public function obje($tempName,$tempDegree)
{
$this->index = 0;
$this->subset = array();
$this->name = $tempName;
$this->degree = $tempDegree;
}
/* Nesnenin degree sini artýrýr. */
public function degreeRaise()
{
$this->degree += 1;
}
// getter function
public function getName() {
return $this->name;
}
// getter function
public function getDegree() {
return $this->degree;
}
// getter function
public function getSubset() {
return $this->subset;
}
public function setSubset($sub)
{
$this->subset[] = $sub;
$this->index++;
}
}
function indexOfObje($str,$array)
{
$count = 0;
foreach( $array as $row) {
if(strcmp($row->getName(),$str) == 0)
return $count;
$count++;
}
return -1;
}
$pathojens = array();
$groups = array();
$types = array();
$index;
// arama sonucundaki satirlara gore islem yapilir.
for($row = 0; $row < $rowcount; $row++) {
$pathojen = $resultsarray2[$row][2];
$group = $resultsarray2[$row][0];
$type = $resultsarray2[$row][1];
//echo $type."---".$group."***".$pathojen."????";
if(($index = indexOfObje($pathojen,$pathojens)) > -1) {
$pathojens[$index]->degreeRaise(); /* Onceden sayýlan bir pathojen ise degree si artýtýlýr.
Bu durum type ve grubunda onceden sayýldýgýný gosterir,
ve onlarýnda degree si artýrýlýr.*/
$groups[indexOfObje($group,$groups)]->degreeRaise();
$types[indexOfObje($type,$types)]->degreeRaise();
}
else if(($index = indexOfObje($group,$groups)) > -1) {
$groups[$index]->degreeRaise(); /* Onceden sayýlan bir grup ise degree si artýtýlýr.
Bu durum type indaonceden sayýldýgýný gosterir,
ve onunda degree si artýrýlýr.*/
//echo $types[0]->getName();
//echo $type.indexOfObje($type,$types);
$types[indexOfObje($type,$types)]->degreeRaise();
/* Yeni bir pathojen objesi olusturulur.Grubunun alt
kumesine konulur ve pathojen dizisine atýlýr.*/
$newObje = new obje($pathojen,1);
$pathojens[] = $newObje;
$groups[indexOfObje($group,$groups)]->setSubset($pathojen);
}
else if(($index = indexOfObje($type,$types)) > -1) {
$types[$index]->degreeRaise(); /* Onceden sayýlan bir type ise degree si artýtýlýr.*/
/* Yeni bir pathojen objesi olusturulur.Grubunun alt
kumesine konulur ve pathojen dizisine atýlýr.*/
$newObje = new obje($pathojen,1);
$pathojens[] = $newObje;
/* Yeni bir pathojen objesi olusturulur.Grubunun alt
kumesine konulur ve pathojen dizisine atýlýr.*/
$newObje2 = new obje($group,1);
$groups[] = $newObje2;
$groups[indexOfObje($group,$groups)]->setSubset($pathojen);
$types[indexOfObje($type,$types)]->setSubset($group);
}
else { /* Yeni bir type,group ve pathojenin oldugu durum */
/* Yeni bir pathojen objesi olusturulur.Grubunun alt
kumesine konulur ve pathojen dizisine atýlýr.*/
$newObje = new obje($pathojen,1);
$pathojens[] = $newObje;
/* Yeni bir group objesi olusturulur.Type nin alt
kumesine konulur ve groups dizisine atýlýr.*/
$newObje2 = new obje($group,1);
$groups[] = $newObje2;
/* Yeni bir type objesi olusturulur,type dizisine atýlýr.*/
$newObje3 = new obje($type,1);
$types[] = $newObje3;
$groups[indexOfObje($group,$groups)]->setSubset($pathojen);
$types[indexOfObje($type,$types)]->setSubset($group);
}
}
/* Datalar flashýn okuyabilmesi icin xmldosyaya yazilacak. */
$document = new DOMDocument();
$document->formatOutput = true;
$root = $document->createElement( "PieChart" );
$document->appendChild( $root );
echo '<?xml version="1.0" encoding="UTF-8"?>';
/* Tür dizisinin boyutu xml e yazýlýr. */
$block = $document->createElement( "datas" );
$size= $document->createElement( "sizeOfType" );
$size->appendChild( $document->createTextNode( count($types) ) );
$block->appendChild($size);
$root->appendChild( $block );
/* Grup dizisinin boyutu xml e yazýlýr. */
$block = $document->createElement( "datas" );
$size= $document->createElement( "sizeOfGroup" );
$size->appendChild( $document->createTextNode( count($groups) ) );
$block->appendChild($size);
$root->appendChild( $block );
/* Strain dizisinin boyutu xml e yazýlýr. */
$block = $document->createElement( "datas" );
$size= $document->createElement( "sizeOfPathojen" );
$size->appendChild( $document->createTextNode( count($pathojens) ) );
$block->appendChild($size);
$root->appendChild( $block );
foreach($types as $type) {
$block = $document->createElement( "datas" );
$size= $document->createElement( "typeName" );
$size->appendChild( $document->createTextNode( $type->getName() ) );
$block->appendChild($size);
$root->appendChild( $block );
$block = $document->createElement( "datas" );
$size= $document->createElement( "typeDegree" );
$size->appendChild( $document->createTextNode( $type->getDegree() ) );
$block->appendChild($size);
$root->appendChild( $block );
}
/* her tür icin alt kume elemanlarý tek tek yazilir. */
$count = 0;
foreach($types as $type) {
/* her tür icin alt kume boyutu yazilir. */
$block = $document->createElement( "datas" );
$size= $document->createElement( "sizeOfSubset" );
$size->appendChild( $document->createTextNode( count($type->getSubset()) ) );
$block->appendChild($size);
$root->appendChild( $block );
for($count2 = 0; $count2 < count($type->getSubset()); $count2++) {
$block = $document->createElement( "datas" );
$size= $document->createElement( "subsetOfType" );
$subset = $type->getSubset();
$size->appendChild( $document->createTextNode( $subset[$count2] ) );
$block->appendChild($size);
$root->appendChild( $block );
}
$count++;
}
foreach($groups as $group) {
$block = $document->createElement( "datas" );
$size= $document->createElement( "groupName" );
$size->appendChild( $document->createTextNode( $group->getName() ) );
$block->appendChild($size);
$root->appendChild( $block );
$block = $document->createElement( "datas" );
$size= $document->createElement( "groupDegree" );
$size->appendChild( $document->createTextNode( $group->getDegree() ) );
$block->appendChild($size);
$root->appendChild( $block );
}
/* her grup icin alt kume elemanlarý tek tek yazilir. */
$count = 0;
foreach($groups as $group) {
/* her grup icin alt kume boyutu yazilir. */
$block = $document->createElement( "datas" );
$size= $document->createElement( "sizeOfSubset2" );
$size->appendChild( $document->createTextNode( count($group->getSubset()) ) );
$block->appendChild($size);
$root->appendChild( $block );
for($count2 = 0; $count2 < count($group->getSubset()); $count2++) {
$block = $document->createElement( "datas" );
$size= $document->createElement( "subsetOfType2" );
$size->appendChild( $document->createTextNode( $group->getSubset()[$count2] ) );
$block->appendChild($size);
$root->appendChild( $block );
$block = $document->createElement( "datas" );
$size= $document->createElement( "degree" );
// pathojenin pathojenler arrayindeki indexi bulunur.
$in = indexOfObje($group->getSubset()[$count2],$pathojens);
// pathojenin degree si yazilir.
$size->appendChild( $document->createTextNode( $pathojens[ $in ]->getDegree()) );
$block->appendChild($size);
$root->appendChild( $block );
}
}
$document->saveXML();
$document->save("chart.xml");
/* Flashi ekrana bas */
if($deger == "Pie Chart")
{
echo '
<EMBED ID="Shockwave" SRC="pie_chart.swf" HEIGHT=400 WIDTH=950 PALETTE=BACKGROUND Quality=AutoLow Loop=FALSE Play=TRUE
Scale=ShowAll SAlign=L ALT="" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer/"></OBJECT></center>';
}
else if($deger == "Bar Chart")
{
echo' <EMBED ID="Shockwave2" SRC="bar_chart.swf" HEIGHT=600 WIDTH=950 PALETTE=BACKGROUND Quality=AutoLow Loop=FALSE Play=TRUE
Scale=ShowAll SAlign=L ALT="" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer/"></OBJECT></center>';
}
include("foot.php");
?>
$block = $document->createElement( "datas" );
$size= $document->createElement( "typeDegree" );
$size->appendChild( $document->createTextNode( $type->getDegree() ) );
$block->appendChild($size);
$root->appendChild( $block );
}
/* her tür icin alt kume elemanlarý tek tek yazilir. */
$count = 0;
foreach($types as $type) {
/* her tür icin alt kume boyutu yazilir. */
$block = $document->createElement( "datas" );
$size= $document->createElement( "sizeOfSubset" );
$size->appendChild( $document->createTextNode( count($type->getSubset()) ) );
$block->appendChild($size);
$root->appendChild( $block );
for($count2 = 0; $count2 < count($type->getSubset()); $count2++) {
$block = $document->createElement( "datas" );
$size= $document->createElement( "subsetOfType" );
$subset = $type->getSubset();
$size->appendChild( $document->createTextNode( $subset[$count2] ) );
$block->appendChild($size);
$root->appendChild( $block );
}
$count++;
}
foreach($groups as $group) {
$block = $document->createElement( "datas" );
$size= $document->createElement( "groupName" );
$size->appendChild( $document->createTextNode( $group->getName() ) );
$block->appendChild($size);
$root->appendChild( $block );
$block = $document->createElement( "datas" );
$size= $document->createElement( "groupDegree" );
$size->appendChild( $document->createTextNode( $group->getDegree() ) );
$block->appendChild($size);
$root->appendChild( $block );
}
/* her grup icin alt kume elemanlarý tek tek yazilir. */
$count = 0;
foreach($groups as $group) {
/* her grup icin alt kume boyutu yazilir. */
$block = $document->createElement( "datas" );
$size= $document->createElement( "sizeOfSubset2" );
$size->appendChild( $document->createTextNode( count($group->getSubset()) ) );
$block->appendChild($size);
$root->appendChild( $block );
for($count2 = 0; $count2 < count($group->getSubset()); $count2++) {
$block = $document->createElement( "datas" );
$size= $document->createElement( "subsetOfType2" );
/* LINE 249 */
$size->appendChild( $document->createTextNode( $group->getSubset()[$count2] ) );
$block->appendChild($size);
$root->appendChild( $block );
$block = $document->createElement( "datas" );
$size= $document->createElement( "degree" );
// pathojenin pathojenler arrayindeki indexi bulunur.
$in = indexOfObje($group->getSubset()[$count2],$pathojens);
// pathojenin degree si yazilir.
$size->appendChild( $document->createTextNode( $pathojens[ $in ]->getDegree()) );
$block->appendChild($size);
$root->appendChild( $block );
}
}
$document->saveXML();
$document->save("chart.xml");
/* Flashi ekrana bas */
if($deger == "Pie Chart")
{
echo '
<EMBED ID="Shockwave" SRC="pie_chart.swf" HEIGHT=400 WIDTH=950 PALETTE=BACKGROUND Quality=AutoLow Loop=FALSE Play=TRUE
Scale=ShowAll SAlign=L ALT="" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer/"></OBJECT></center>';
}
else if($deger == "Bar Chart")
{
echo' <EMBED ID="Shockwave2" SRC="bar_chart.swf" HEIGHT=600 WIDTH=950 PALETTE=BACKGROUND Quality=AutoLow Loop=FALSE Play=TRUE
Scale=ShowAll SAlign=L ALT="" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer/"></OBJECT></center>';
}
include("foot.php");
?>
截图如下。
谢谢。