新错误!! 多谢你们!工作,但新的错误弹出55行:(我要编辑,并用"// LINE 55"标记行号,在我原来的帖子中^^
Parse error: syntax error, unexpected '.' in C:\wamp\www\flueforumdk\config.php on line 55
在尝试创建函数时,我得到一个解析错误,我的时间戳代码在我尝试将其放入函数之前运行良好,因此我可以重复使用它而不会在代码中造成大麻烦.我从'cmd.php'的mysql数据库中获取unix时间,并将我的函数放在'config.php'这里是我的错误:
Parse error: syntax error, unexpected ''$UNIX_TIME_SECONDS'' (T_CONSTANT_ENCAPSED_STRING), expecting '&' or variable (T_VARIABLE) in C:\wamp\www\flueforumdk\config.php on line 33
这是'CMD.PHP'的代码:
$GET_UNIX_STAMP_FROM_DB = $art[tidspunkt]; $UNIX_TIME_SECONDS = $GET_UNIX_STAMP_FROM_DB; echo timestamp_converter($UNIX_TIME_SECONDS);
以及'CONFIG.PHP'中我的代码:
## TIMESTAMP CONVERTER FUNCTION function timestamp_converter('$UNIX_TIME_SECONDS'){ // UDREGNING FRA UNIX TIME $tid = time() - $UNIX_TIME_SECONDS; $timer = floor($tid/3600); $minutter = floor($tid/60); $dage = floor($timer / 24); $uge = floor($dage / 7); $month = floor($dage / 30.5); $aar = floor($dage / 365); if($tid < 60){ echo"$tid sekunder"; } elseif ($tid > 60){ echo""; } // THIS IS LINE 33 if($minutter == 0){ echo""; } elseif ($minutter < 60){ if($minutter == 1){ echo"$minutter minut"; }else{ echo"$minutter minutter"; } } if($timer == 0){ echo""; } elseif ($timer < 24){ if($timer == 1){ echo"$timer time"; }else{ echo"$timer timer"; } } //LINE 55 if($dage == 0){ echo""; } elseif ($dage < 7){ if($dage == 1){ echo"$dage dag"; }else{ echo"$dage dage"; } } if($uge == 0){ echo""; } elseif ($uge < 4){ if($uge == 1){ echo"$uge uge"; }else{ echo"$uge uger"; } } if($month == 0){ echo""; } elseif ($month < 12){ if($month == 1){ echo"$month måned"; }else{ echo"$month måneder"; } } if($aar == 0){ echo""; } elseif ($aar > 0){ if($aar == 1){ echo"$aar år"; }else{ echo"$aar år"; } } }
小智.. 5
这条线
function timestamp_converter('$UNIX_TIME_SECONDS'){
一定是
function timestamp_converter($UNIX_TIME_SECONDS){
没有引号,因为这是传入参数,此时没有具体值.
这条线
function timestamp_converter('$UNIX_TIME_SECONDS'){
一定是
function timestamp_converter($UNIX_TIME_SECONDS){
没有引号,因为这是传入参数,此时没有具体值.