My Assistant
![]() ![]() |
|
|
Apr 17 2009, 02:17 AM
Post
#1
|
|
|
UtterAccess Addict Posts: 134 From: Singapore |
Hello,
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. <html> <body><?php echo "Hello World"; // or print "Hello World"; ?></body> </html> 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. |
|
|
|
Apr 17 2009, 03:14 AM
Post
#2
|
|
|
Retired Moderator Posts: 11,289 From: Milwaukee, WI |
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: phpExample1.html 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). CODE <html> <head><title>PHP Example 1</title></head> <body> <h2>PHP Example 1</h2><br /> <?php echo "Hello World"; // or print "Hello World"; ?> </body> </html> 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: http://yourDomainName.com/phpExample1.html 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... |
|
|
|
Apr 17 2009, 06:50 AM
Post
#3
|
|
|
UtterAccess Addict Posts: 134 From: Singapore |
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 (IMG:http://www.utteraccess.com/forum/style_emoticons/default/sad.gif) ) Still would be tough nut to add MySQL to php. But first step is done! |
|
|
|
Apr 17 2009, 06:58 AM
Post
#4
|
|
|
Retired Moderator Posts: 11,289 From: Milwaukee, WI |
Fantastic! Glad you found a solution. It gets easier from this point on.
Good luck on the project. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 20th May 2013 - 03:29 PM |