<html>
<head>
<title> Who Are You ? </title>
</head><body>
<?php
//var $uname;
$uname=3;
print($uname)
?>
</body>
</html>

解决方案 »

  1.   

    ---------who_are_you.php
    <html>
    <head>
    <title> Who Are You ? </title>
    <style>
    <!--
    body,td,input,p{font-size:12px}
    -->
    </style>
    </head><body>
    <form action="you_are.php" method="get">
    Please enter your name:<br />
    I am...
    <?php
    print('<input type="text" name="person" value="'.$_GET['person'].'" size="15" />');
    ?>
    <input type="submit" value="Go!" />
    </form>
    </body>
    </html>-------------you_are.php
    <html>
    <head>
    <title> You Are... </title>
    <style>
    <!--
    body,td,input,p{font-size:12px}
    -->
    </style>
    </head><body>
    <?php
    print('Well,hello<b><font color="#ff0000">'.urldecode($_GET['person']).'</font></b>,nice to meet you!');
    print('<br />');
    print('<a href="who_are_you.php?person='.urlencode($_GET['person']).'">Back to Who Are You ?</a>');
    ?>
    </body>
    </html>第一次运行时浏览器提示:Notice: Undefined index: person in c:\inetpub\wwwroot\myphp\old\index.php on line 16第一次运行时$person变量未被定义,怎样才能定义呢??
      

  2.   

    1、只有在类定义中才需要使用var声明类的属性
    2、....
    <?php
    if(isset($_GET['person']))
    print('<input type="text" name="person" value="'.$_GET['person'].'" size="15" />');
    ?>
    ....
    <?php
    if(isset($_GET['person'])) {
    print('Well,hello<b><font color="#ff0000">'.urldecode($_GET['person']).'</font></b>,nice to meet you!');
    print('<br />');
    print('<a href="who_are_you.php?person='.urlencode($_GET['person']).'">Back to Who Are You ?</a>');
    }
    ?>