Full Version: php "Hello world" ABC question.
UtterAccess Discussion Forums > And More... > PHP, Perl, MySQL and Postgres
I am doing my first steps with php. I liked this language, but please help me to do first step.
I bought domain.
If I want to put static html files I put them in \web or \public_html folder.
But I want to see how simplest php file works, famous Hello World.

echo "Hello World"; // or print "Hello World";

Well, I save it as hello.php
Where should I put it - in root or in \php folder.
How can I see resulted html file
www.mysite.com/hello.php or how?

My next question willl be about PHP-MySQL construction of dynamic menu. If you can now send me to proper link, I'll be happy.
This page isn't bad: http://www.webdev-tutorials.com/?p=6
Note the type where "pho" really means "php"!

It is amazing how difficult it is to find a good example to provide. Most assume you are using some product or skip steps.

First - you need to create an .html page that calls PHP as in your example. Save that to your webserver with a name like:

Note that you are creating a HTML page that a browser will see. The <?php .... /php> stuff is embedded in the HTML and your web server makes it work (if it is properly configured to support PHP).
<head><title>PHP Example 1</title></head>
  <h2>PHP Example 1</h2><br />
    echo "Hello World"; // or print "Hello World";

If your hosting account is setup for PHP then that is all you should have to write. Upload to your file area and open a browser and navigate to:


You don't have to create a .PHP file because you have embedded the PHP code within your HTML file by using the <?php> tag.

Hope that helps...
Thank you.
Alas, your advise didn't help me directly, but forced me to try variants, and I succeeded!
I think it is somewhere in Hosting setting where set up whether you need to save .html or .php

My hosting provider is hostmonster, so it is equipped with all I need.
Solution was
to save my example as hello.php
put it into public_html folder
and type in browser www.mysite.com/hello.php

In case of saving as html it shows raw php code in View Source.

I am happy now to try to build php files sad.gif)

Still would be tough nut to add MySQL to php. But first step is done!
Fantastic! Glad you found a solution. It gets easier from this point on.

Good luck on the project.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.