duanchun2349
duanchun2349
2014-12-21 16:41

php urlencode不起作用或者是别的东西

  • urlencode
  • php

I am trying my hand in PHP and got stuck with the urlencode. Please see the two code

first document@

<HTML>
   <HEAD>
      <TITLE>My Movie Site</TITLE>
   </HEAD>
   <BODY>
    <?php 

    // delete as per page 34 define ('FAVMOVIE', 'The life of Brian'); 
    echo    'My favorite movie is ';
    echo    $_GET['favmovie'];
    echo '<br/>';
    $movierate = 5;
    echo 'My movie rating for this movie is: ';
    echo $movierate;
    ?>

   </BODY>
</HTML>

Second document

<HTML>

   <HEAD>

   <TITLE>Find my Favorite Movie!</TITLE>

   </HEAD>

   <BODY>
            <?php 

                $myfavmovie = urlencode ('Life of Brian');
                echo    '<a href = "http://php.aryapratinidhisabha.org.uk?favmovie=$myfavmovie\">'  ;
                echo    'Click here to see information about my favorite movie!' ;
                echo    '</a>'  ;

            ?>

   </BODY>

</HTML>

I am getting the following result all the time:

In the first line: "My favorite movie is $myfavmovie\"

In the second line: "My movie rating for this movie is: 5"

My questoins are:

  1. Why am I not getting in the first line: "My favorite movie is Life of Brian"?
  2. The book says that in the url the result should be "http://php.aryapratinidhisabha.org.uk/?favmovie=$Life+of+Brian instead it gives this http://php.aryapratinidhisabha.org.uk/?favmovie=$myfavmovie. Why is that?

Thanks,

Naveen

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐