请大家帮我看看,源代码如下:
<body>
<?php       
$student=array(array("student_id"=>"0001", "name"=>"李宵明", "gender"=>"男", "birthdate"=>"1988-10-06"),               array("student_id"=>"0002", "name"=>"唐小芙", "gender"=>"女", "birthdate"=>"1989-8-16"),               array("student_id"=>"0003", "name"=>"张贵宝", "gender"=>"男", "birthdate"=>"1988-9-12"));     
 $n=count($student);      
 if(!isset($_GET["id"])) {          
     print("<table border=\"1\"  width=\"300\">\n");         
     print("<caption>学生列表</caption>\n");         
     printf("<tr bgcolor=\"#CCCCCC\"><th>学号</th><th>姓名</th><th>操作</th></tr>\n");         
     for($i=0; $i<$n;$i++){              
        printf("<tr align=\"center\"><td>%s</td><td>%s</td><td><a href=%s?id=%s>查看详细信息</a></td></tr>\n", $student[$i]["student_id"], $student[$i]["name"], $PHP_SELF, $student[$i]["student_id"]);         }      
  print ("</table>\n");    } 
  else {       
     $id=$_GET["id"];       
 for($i=0;$i<$n;$i++){              
    if($id==$student[$i]["student_id"]) break;      }      
 print ("<p><b>学生详细信息</b></p><br>\n");     
 printf("学号: %s<br/>\n姓名: %s<br/>\n性别: %s<br/>\n生日:%s</p>\n", $student[$i]["student_id"], $student[$i]["name"], $student[$i]["gender"], $student[$i]["birthdate"]);    
 printf("<a href=%s>返回</a>\n", $PHP_SELF);   }
 ?>
</body>请大家看看,红色部分出错,出错提示如下:Notice: Undefined variable: PHP_SELF in C:\wamp\www\page5-12.php on line 17
不知道为什么还有这个提示???
另外, 请教一下echo , print, printf的区别和用法,谢谢大家了

解决方案 »

  1.   

    echo , print基本上理解为一样。但用echo的多
    printf() 函数输出格式化的字符串。
    printf(format,arg1,arg2,arg++)
    format 必需。规定字符串以及如何格式化其中的变量。 
    arg1 必需。规定插到格式化字符串中第一个 % 符号处的参数。 
    arg2 可选。规定插到格式化字符串中第二个 % 符号处的参数。 
    arg++ 可选。规定插到格式化字符串中第三、四等等 % 符号处的参数。 
      

  2.   

    echo print print_r 都是输出函数,print_r 格式化函数输出,速度相应慢一些。一般都是用echo .
      
    PHP_SELF   没有加 $_SEVER[]