登录 | 注册 | FAQ
Anonymous

Simple php code, _GET does not work

+ 发表回复

3 篇帖子 分页: 1 / 1


Simple php code, _GET does not work

machiel » 周五 7月 04, 2014 10:08 am

Hello,

I am a novice with using php, so maybe I am asking for something really obvious, but I just don't see what I am doing wrong.
From this webpage (http://html.net/tutorials/php/lesson10.php), I picked the following example. In a file, named "people.php", I have the following:
代码: 全选
<?php
echo "<h1> Hello " . $_GET["name"] . "</h1> ";
?>


I also tried:
代码: 全选
<html>
   <head>
   <title>Query string</title>
   </head>
   <body>

<?php
echo "<h1> Hello " . $_GET["name"] . "</h1> ";
?>

   </body>
</html>


However, when I open the page with file:///.../html/people.php?name=Joe, on the screen I only get the following line on the screen:

Hello " . $_GET["name"] . " "; ?>

Is this because I am opening it as a file, instead of with http?

Best regards,

Machiel
头像

machiel

  • 帖子: 3
  • 注册: 周五 7月 04, 2014 9:59 am

Re: Simple php code, _GET does not work

XainPro » 周六 7月 05, 2014 12:33 am

You are opening it direct in browser use XAMPP to open it
you can learn about XAMPP here
http://html.net/tutorials/php/lesson2b.php
头像

XainPro

  • 帖子: 3933
  • 注册: 周五 2月 17, 2012 8:10 pm

Re: Simple php code, _GET does not work

machiel » 周六 7月 05, 2014 11:29 am

Hi,

Thanks for your fast replies. I see that to test PHP code, the page either has to be interpreted via a server or via XAMPP. Just opening it in a browser is not good enough. I wasn't aware of that. Thanks for clearing that up for me.
Cheers,

Machiel
头像

machiel

  • 帖子: 3
  • 注册: 周五 7月 04, 2014 9:59 am


+ 发表回复

分页: 1 / 1