PHP echo not displaying in HTML
I'm new to PHP and I'm following the PHP tut on w3schools. I am using Eclipse's latest IDE version (3.6 I think). for my script helloDriver.php it functions fine when ran as a php script. it doesn't on my html file especially when I use a similar method to the example from w3schools: http://www.w3schools.com/PHP/php_forms.asp
This would be my code for helloDriver.php:
<html>
<body>
go
<?php
echo "giga";
?>
power rangers
</body>
</html>
This is my code for homepage.html
<html>
<body>
Hey
<form action="helloDriver.php">
<input type="submit />
</body>
</html>
"Hey" and "go" both display so I know that the php file is being called but I don't know why the echo command doesn't.
Even before this I copied line by line with what the w3schools example was开发者_运维知识库 with the exception of welcome.php since that is helloDriver.php
How I access the html file is double clicking it since Eclipse doesn't have any options to run the program. Any ideas what I am doing wrong?
Where are these files hosted? I'm guessing your web server (e.g., Apache or IIS) isn't configured to run .php
files through the PHP interpreter, but instead is serving them statically.
I'm having a really hard time working out what your question is.
Some problems with your HTML file are:
- You're missing the closing
</form>
tag - You haven't closed the quotes on your submit button.
The complete markup should probably be more like
<form action="helloDriver.php">
<input type="submit" />
</form>
Another thing that might be the problem, you need to access the PHP scripts through a web server. Have you installed something like XAMPP?
I ended up figuring it out. Thank you guys for help and thanks for suggesting XAMPP. Installed it from this link (googling XAMPP works just as well): http://www.apachefriends.org/en/xampp-windows.html#1173
It was straightforward and easy to set up. Set the destination to install on the C: drive. Also stumbled across this tut vid on how to set up a PHP project using PHP, XAMPP, and Eclipse: http://www.youtube.com/watch?v=hfHEmZXJLgw
I should be able to figure things through trial and error. Thanks again!
精彩评论