Free Credit Report - Debt Consolidation - Web Hosting - TV News - Debt Consolidation

PDA

View Full Version : I would like to learn how to write php...


chengcj
May 9th 2006, 3:34 am
I have wrote the following php in a notepad:

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>

I saved it as hello.php, then I use IE to open the file but nothing happens=_=

I have installed php 5, do I need to configure anything on my computer so that I can open php files on my computer?

T0PS3O
May 9th 2006, 3:39 am
The code is correct so my guess is you have no working Apache server on your machine. What do you get when you browse to http://localhost ?

Google for 'download PHP MySQL Apache' or similar and get one of those packaged deals that install all you need and talk you through setting it up.

http://www.wampserver.com/en/download.php for instance.

TwistMyArm
May 9th 2006, 5:23 am
Forget installing PHP, Apache and MySQL separately.

Do yourself a favour and install XAMPP for Windows from apachefriends.org.

Remember: PHP is a server side scripting language. It needs to be interpreted by a web server (eg. Apache running on localhost). Web browsers themselves don't interpret PHP scripts.

chengcj
May 9th 2006, 6:08 am
Thank you very much!

I have installed xampp

But I still don't know how to run my hello.php? Do I need to put hello.php to a certain directory? And then run it through the cmd console?

TwistMyArm
May 9th 2006, 6:13 am
Once XAMPP is installed, you access the server by using your browser to go to http://localhost . http://localhost/xampp/index.php should have a link for more documentation.

In your installation directory, there should be a directory called htdocs. Put your hello.php file there.

http://localhost uses this htdocs directory as your 'webroot'. If you send your browser to http://localhost/hello.php , it should work as expected.