照着《细说php》打的第一个php程序,浏览器里运行出现错误:
Parse error: syntax error, unexpected T_STRING in C:\lamp\htdocs\info.php on line 14把程序贴上来大家帮我看看吧:<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>get the info of the server in my first php</title>
</head>
<body>
<?php
//获取服务器标识的字符串
$sysos=$_SERVER["SERVER_SOFTWARE"];
//获取PHP服务器版本
$sysversion=PHP_VERSION; //连接mysql数据库并获取mysql数据库版本信息
mysql_connect("localhost","root","555");
$mysqlinfo=mysql_get_server_info(); //从服务器中获取GD库的信息
if(function_exists("gd_info"))
{
$gd=gd_info();
$gdinfo=$gd['GD Version'];
}
else
{
$gdinfo="unknown";
} //从GD库中查看是否支持FreeType字体
$freetype=$gd["FreeType Support"]?"yes":"no"; //从PHP配置文件中获得是否可以远程文件获取
$allowurl=ini_get("allow_url_fopen")?"yes","no"; //从PHP配置文件中获得最大上传限制
$max_upload=ini_get("file_uploads")?ini_get("upload_max_filesize"):"Disabled"; //从PHP配置文件中获得脚本的最大执行时间
$max_ex_time=ini_get("max_execution_time")."s"; //获取服务器时间,东八区应写成Etc/GMT-8
date_default_timezone_set("Etc/GMT-8");
$systemtime=date("Y-m-d H:i:s",time()); //以表格的方式把获得的信息传给浏览器
echo"<table align=center cellspacing=0 cellpadding=0>";
echo"<caption><h2>System_info</h2></caption>";
echo"<tr><td>Web_server:</td><td>$sysos</td></tr>";
echo"<tr><td>PHP_version:</td><td>$sysversion</td></tr>";
echo"<tr><td>Mysql_version:</td><td>$mysqlinfo</td><tr>";
echo"<tr><td>GD_version:</td><td>$gdinfo</td></tr>";
echo"<tr><td>FreeType:</td><td>$freetype</td></tr>";
echo"<tr><td>remote_file_get:</td><td>$allowurl</td></tr>";
echo"<tr><td>max_upload:</td><td>$max_upload</td></tr>";
echo"<tr><td>max_execu_time:</td><td>$max_ex_time</td></tr>";
echo"<tr><td>server_time:</td><td>$systemtime</td></tr>";
echo"</table>";
?>
</body>
</html>
14行正好是获取mysql信息的那一行。

解决方案 »

  1.   


    <html>
        <head>
            <meta http-equiv="content-type" content="text/html; charset=gb2312">
            <title>get the info of the server in my first php</title>
        </head>
        <body>
    <?php
        //获取服务器标识的字符串
       $sysos=$_SERVER["SERVER_SOFTWARE"];
        //获取PHP服务器版本
    //$sysversion=PHP_VERSION;//这个我不知道干什么用的。。注释了就好。32行也有错误
           //连接mysql数据库并获取mysql数据库版本信息
        mysql_connect("localhost","root","555");
        $mysqlinfo=mysql_get_server_info();    //从服务器中获取GD库的信息
        if(function_exists("gd_info"))
        {
            $gd=gd_info();
            $gdinfo=$gd['GD Version'];
        }
        else
        {
            $gdinfo="unknown";
        }    //从GD库中查看是否支持FreeType字体
        $freetype=$gd["FreeType Support"]?"yes":"no";    //从PHP配置文件中获得是否可以远程文件获取
        $allowurl=ini_get("allow_url_fopen")?"yes":"no";   //这里错误把,换成:
        //从PHP配置文件中获得最大上传限制
        $max_upload=ini_get("file_uploads")?ini_get("upload_max_filesize"):"Disabled";    //从PHP配置文件中获得脚本的最大执行时间
        $max_ex_time=ini_get("max_execution_time")."s";    //获取服务器时间,东八区应写成Etc/GMT-8
        date_default_timezone_set("Etc/GMT-8");
        $systemtime=date("Y-m-d H:i:s",time());    //以表格的方式把获得的信息传给浏览器
        echo"<table align=center cellspacing=0 cellpadding=0>";
        echo"<caption><h2>System_info</h2></caption>";
        echo"<tr><td>Web_server:</td><td>$sysos</td></tr>";
        echo"<tr><td>PHP_version:</td><td>$sysversion</td></tr>";
        echo"<tr><td>Mysql_version:</td><td>$mysqlinfo</td><tr>";
        echo"<tr><td>GD_version:</td><td>$gdinfo</td></tr>";
        echo"<tr><td>FreeType:</td><td>$freetype</td></tr>";
        echo"<tr><td>remote_file_get:</td><td>$allowurl</td></tr>";
        echo"<tr><td>max_upload:</td><td>$max_upload</td></tr>";
        echo"<tr><td>max_execu_time:</td><td>$max_ex_time</td></tr>";
        echo"<tr><td>server_time:</td><td>$systemtime</td></tr>";
        echo"</table>";
    ?>
        </body>
    </html>
      

  2.   


    谢谢你的回答!也就是说浏览器把错误的行号给报错了么?我也不知道那个sysversion有什么用……后面那个是我打太顺了给弄成逗号了。再次感谢!
      

  3.   

    还是得说一句,出错的是在PHP_VERSION那里,错误原因是最后的分号我居然用了全角的……坑爹的错误