\"" />
开发者

displaying the function of php

i have a php code here and wondering how can this display what you have wrote in the box: i did this and it did display this one: "$input"; ?> "

 <html>
 <head></head>
 <body>
 <form action="message.php" method="post">
 Ente开发者_开发问答r your message: <input type="text" name="msg" size="30">
 <input type="submit" value="Send">
 </form>
 </body>
 </html> 

=============== this is my message.php

   <html>
   <head></head>
   <body>

     <?php
     // retrieve form data
     $input = $_POST['msg'];
      // use it
     echo "You said: <i>$input</i>";
     ?>

    </body>
    </html> 

=======

This is what i get as view page source:

        <html>
        <head></head>
         <body>

          <?php
           // retrieve form data
          $input = $_POST['msg'];
        // use it
         echo "You said: <i>$input</i>";
            ?>

            </body>
             </html> 


It's weird actually.Check once by typing only localhost on your web browser,then run you page with the correct path.If it shows your HTML page,then go for $_REQUEST in place of POST.Just add this on your message.php : -

<?php
print "<pre>";print_r($_POST);print "</pre>";
print "<pre>";print_r($_REQUEST);print "</pre>";
?>

Check what output you get after this...You can easily debug things like this.


The .php-file is not interpreted via your web-server (like Apache). You can not open the file in your browser via File->Open but you have to access it via a valid URL (like http://localhost/myphpfile.php).

Also check if the php interpreter module is enabled in your webserver.


If you view a html file from Notepad++, it will open in the browser from its location on the disk. Then the link in the form points to your php file on the disk. (The address field will read file:/// and the php won't be parsed.)
Notepad++ doesn't know that the same file can be reached via http://localhost/namedform.htm so you'll have to access it via localhost in order to get the php parsing for message.php to work. Now your address field should start with http://. Later you can just hit "reload" in your browser after you made and !saved! any changes.

edit:
Although reloading php pages after edit & save seems to me like the natural thing even after years of php programming, here are some solutions that let you preview your file from notepad++ via the web server:

  1. Add some javascript to the html file you want to preview that checks if the address starts with http:// or file:///. If it is the latter, reload the file from http://localhost.
  2. Search the settings of notepad++ for the default preview options. Change to preview from localhost. Maybe you need an extension for that. I'm not that deep into the subject.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜