所以我有一个很长的代码,但是当我运行它时,我收到错误: "解析错误:语法错误,意外的文件结束"
我用谷歌搜索了一下,在我看来,最常见的罪魁祸首是错过了一个支架。好吧,我认为这里的问题也是如此。但请允许我详细说明一下:
在我在线获取代码之前,这里是我的代码的简要概述:
这是我认为导致错误的有趣事情。所以在主循环中还有另外两个for循环,我将其命名为二级和三级循环。如果我为主循环放置结束括号(a"}")在第三个循环开始之前,主循环的起始括号和结束括号连接(意味着,如果你单击其中一个括号,两者都会点亮绿色,因此它们连接)。但是,如果我在三级循环开始后放置结束括号,主循环的起始括号将不会与它连接。如果我在次级回路之前切断三级回路(从而使次级回路成为次级回路,反之亦然)并不重要,如果主回路的末端支架放置在后,则它将不会与起始支架连接。三级(第三)循环。
我已经多次查看过我的代码了。除了这两个支架外,所有其他支架相互连接。我没有看到任何单独的括号。也许它是某种内部错误,它应该在理论上起作用,但它实际上并不存在。坦率地说,我不是编程天才,所以我在这里发布这个问题:P。
这里是代码(我必须将它放在JavaScript / HTML / CSS片段预览中,因为"代码示例"混淆了文本,因为它认为每个括号都是新的代码示例):
for ($p = 0; $p<=1000;$p++)
{
//the above starting bracket should connect with the bracket all the way down
$ale=$ale*(1+($ale0-$levensverwachting)/(10*$ale0));
$tfr=$tfr*(1+($tfr0-$realtfr)/(10*$tfr0));
$grens=15+(20/$tfr);
if ($grens==30)
{
$grens=30;
}
if ($grens==18)
{
$grens=18;
}
$totaalgeborenen=0;
$houop=0;
$newfactortotaal=1;
$newfactor=1;
$medgb0=1;
$newfactorAr=array();
for ($v=15;$v<=44;$v++)
{
$vbev=$vbev+0.5*$ageAr[$v];
if ($v<= $grens)
{
$newfactor=($v-14)*($tfr/30)/($grens-14);
}
if ($v>$grens)
{
$newfactor=($tfr/30)-($v-$grens)*($tfr/30)/($grens-45);
}
$newlt=$ageAr[$v]*0.5*$newfactor;
$totaalgeborenen=$totaalgeborenen+$newlt;
if ($p>$sy-50)
{
$juist="tfr" . $v;
array_unshift(${"$juist"},$newfactor);
}
//tfr+med geb
$totalfertilityrate=$totalfertilityrate+$newfactor;
$medgb0=$medgb0+($newfactor);
if ($medgb0==1)
{
$medgb=$v;
$medgb0=1;
}
array_push($newfactorAr,1+$newfactor);
if (array_product($newfactorAr)>=1.5 && $houop !=1)
{
$oudfertility=array_product($newfactorAr)/$newfactor;
$goedjuiste=1.5/$oudfertility;
$aob=$v-($newfactor/$goedjuiste)+1;
$houop=1;
}
}
$vbevorign =$vbev;
$newage=$totaalgeborenen;
$totaalgeborenen=0;
$realtfr=$totalfertilityrate;
$totalfertilityrate=0;
$newfactortotaal=1;
$actualnew = round($newage*(1-$imr/1000));
$ageArBG = array_sum($ageAr);
$vbev=0;
array_unshift($ageAr,$actualnew);
array_unshift($ageOrignal1,$actualnew);
$echtebev0 = array_sum($ageAr);
$totaalgehalte=1-$imr/1000;
$special2=0;
$gehalte=1;
$optellen=0;
for ($n2 = 0;$ageAr[$n2]>=1;$n2++)
{
$ageN=$ageAr[$n2];
if ($n2 != 0 && $ageAr[$n2]>=1)
{
if ($ale<=7)
{
$ale=7;
}
$co=pow(M_E,($ale-27.215)/-3.999);
$bes=log(105/$co)/log(110);
if ($co*pow($n2,$bes)<100)
{
$ovka=0.5*log(100-$co*pow($n2,$bes),10);
}
else
{
$ovka = 0;
}
if ($ovka<=0)
{
$ovka=0;
}
$ageAr[$n2]=$ageAr[$n2]*$ovka;
}
if ($n2>0 && $n2<5)
{
$ageBEF=$ageBEF+$ageAr[$n2];
$ageAr[$n2]=$ageAr[$n2]-((5-$n2)/10)*(0.5*$imr/1000)*$ageAr[0];
$ageAF=$ageAF+$ageAr[$n2];
}
if ($ageAr[$n2]<1)
{
$ageAr[$n2]=0;
}
if ($ageAr[$n2]>=1)
{
$gehalte=$ageAr[$n2]/$ageN;
$totaalgehalte=$totaalgehalte*$gehalte;
$optellen=$optellen+$totaalgehalte;
}
if ($ageAr[$n2]<1)
{
$levensverwachting=round($optellen,2);
}
$ageD=$ageN-$ageAr[$n2];
$ageDtot = $ageDtot + $ageD;
$lvAgeD=$ageD*$n2;
$lvAgeDtot=$lvAgeDtot+$lvAgeD;
}
$special2=0;
$totaalgehalte=1-$imr/1000;
$optellen=0;
//child mortality
$childdood=$ageBEF-$ageAF;
$childmortality=round(1000*($childdood+$newage*($imr/1000))/($newage),2);
$ageBEF=0;
$ageAF=0;
$ageArEN=array_sum($ageAr);
//$groei=round(100*($ageArEN/$ageArBG)-100,2);
$br = round(1000*$newage/$ageArEN,1);
$gestorven = $ageDtot+($newage*$imr/1000);
$ageDtot =0;
$dr = round(1000*($gestorven)/$ageArEN,2);
$realale=$lvAgeDtot/$gestorven;
$realelv=$lvAgeDtot/($gestorven-$newage*$imr/1000);
$lvAgeDtot=0;
for ($q=0;$q<=14;$q++)
{
$onder16=$onder16+$ageAr[$q];
}
$onder15perc=round(100*$onder16/$ageArEN,2);
$echtebev = array_sum($ageAr);
if ($p !=$sy)
{
$echtebev = array_sum($ageAr);
}
else
{
$echtebev = array_sum($ageAr);
}
$birthrate = round(1000*($newage)/$echtebev,1);
//$dr = $br-$groei*10;
$dr=round(1000*($gestorven)/$echtebev,1);
$nettogroeiabs=$newage-$gestorven-$emtot+$lalatot;
$groei=round(100*(array_sum($ageAr)/(array_sum($ageAr)-$nettogroeiabs)-1),2);
$lengte = count($ageAr);
$jongeren = 0;
$adults = 0;
for ($io = 0; $io<=$lengte;$io++)
{
if ($io<=14)
{
$jongeren = $jongeren+$ageAr[$io];
}
if ($io>14 && $io<=64)
{
$adults=$adults+$ageAr[$io];
}
}
$jongerenperc = round(100*$jongeren/array_sum($ageAr),2);
$adultsperc = round(100*$adults/array_sum($ageAr),2);
//$groeijaar = round($echtebev/$echtebev0,2);
$medianpop=0;
if ($pop!=0)
{
for ($rt = 0;$rt<=$l;$rt++)
{
if ($medianpop<0.5*array_sum($ageAr))
{
$medianpop=$medianpop+$ageAr[$rt];
}
else
{
$medianage = $rt-round(($medianpop-0.5*array_sum($ageAr))/$ageAr[$rt],2)-1;
$rt=$l+1;
}
}
}
if ($p==999)
{
$elderly=100-$jongerenperc-$adultsperc;
echo "Total Fertility Rate: " . $realtfr . "<br>Birth rate per thousand: " . $birthrate . "<br>Infant mortality rate: " . $imr . "<br>Child mortality rate: " . $childmortality . "<br>Life expectancy: " . $levensverwachting . "<br>Death rate per thousand: " . $dr . "<br>Growth rate in percent: " . $groei . "%<br>Median age: " . $medianage . "<br>People 14 years or younger: " . $jongerenperc . "%<br>People between 15 and 64 years: " . $adultsperc . "%<br>People 65 years or older: " . $elderly;
}
}
//the above ending bracket should connect with the bracket all the way up
&#13;