我所指的语法检查器是一个整洁的小工具,用于在通过tortoiseSVN提交代码之前帮助我检查代码。直到今天我才会迷失方向。
我做了一个简单的函数,以求传递的一个数字的数量级,这个数量级是不完整的,但包括以下内容:
function( $graphMax )
{
$a = (int)log10( $graphMax );
echo "<br><br>GRAPHMAX LOG-10: " . $a . "<br><br>";
$a = pow( 10 , $a );
return $a;
}这将返回该数量级的最低值( 10,000至99,999之间的数字)。
我面临的问题是职能的这一部分:
$a = (int)log10( $graphMax );语法检查器说,当我将整个文件复制/粘贴到它中时,语法中没有错误,但是当我在服务器上提交并运行它时,我得到:
Parse error: syntax error, unexpected '(', expecting T_STRING in /*/global_functions.php on line 364根据请求,这是函数上面的代码::
function countSections( $testID ){要求( 'config.php');
//Connect to database server
$dsl_sqlh = mysql_connect( $dsl_db_host, $dsl_db_user , $dsl_db_pass )
or die ("Unable to connect");
mysql_select_db ( $dsl_db , $dsl_sqlh) or die ("Unable to select database");
//Get Section ID.
//With this we can query the correct section
$secQuery = sprintf("SELECT test_section_name FROM v_ak47_test_section WHERE ak47_testhistory_id= $testID and obsolete = 0");
$secResults = mysql_query($secQuery , $dsl_sqlh);
$rows = mysql_num_rows( $secResults );
if( $rows > 0 )
{
return $rows;
}
else
{
echo "<br><br>Test has no sections! Check test ID provided.<br><br>";
return null;
}}
回答:我没有命名函数。我不知道我是怎么错过的。现在还早..。我需要更多的咖啡:(谢谢大家的帮助!抱歉,太不适合气候了。我最近的几篇文章都是这样的。
发布于 2011-07-22 14:03:18
你需要给你的函数一个名字
function {ENTER NAME HERE}( $graphMax )
{
$a = (int)log10( $graphMax );
echo "<br><br>GRAPHMAX LOG-10: " . $a . "<br><br>";
$a = pow( 10 , $a );
return $a;
}发布于 2011-07-22 14:05:35
这种区别很可能是在服务器上运行PHP5.2,但是在运行语法检查器(默认情况)时,已经检查了5.3。在5.2中不允许匿名函数,但在5.3中允许匿名函数。检查5.2选项并再次运行语法检查器,您将得到与报告的错误相同的结果。
http://php.net/manual/en/functions.anonymous.php
您的语法是有效的5.3,它只是什么都不做。
当有疑问时,请相信服务器说的话:)
https://stackoverflow.com/questions/6791085
复制相似问题