如何从另一个PHP文件获取PHP变量值?(How to get a PHP variable value from another PHP file?)
如何从另一个.php文件获取值帮助我解决这个问题:
<html> <head> </head> <body> <form name='answer' action="file2.php" method="post"> <input type="text" name="what"> <input type="submit" value="Login"> </form> <div><?php echo $answer; ?></div> </body> </html>file2.php文件的代码如下:
<?php if ($_POST['what']==animal){ $answer="dog"; }else{ $answer= "not animal"; }我想知道如何获得变量$ answer与按钮的值,然后我应该在该行放置什么:
how to take the value from another .php file help me fix this:
<html> <head> </head> <body> <form name='answer' action="file2.php" method="post"> <input type="text" name="what"> <input type="submit" value="Login"> </form> <div><?php echo $answer; ?></div> </body> </html>And the code of file2.php file is as below:
<?php if ($_POST['what']==animal){ $answer="dog"; }else{ $answer= "not animal"; }I would like to know how can I get the value of the variable $answer with button, then what should I put at the line :
最满意答案
只需使用requiere
<?php require 'file2.php'; ?>Just use requiere
<?php require 'file2.php'; ?>更多推荐
发布评论