geekette Posted March 4, 2009 Share Posted March 4, 2009 I wrote the following for a class assignment, but unfortunately, it is not showing up correctly on my browser. I know it's not the browser as I have opened other php documents through it. Any help would be appreciated!..: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Hello World</title> </head> <body> <?php $WorldVar = "World"; $SunVar = "Sun" ; $MoonVar = "Moon" ; $WorldInfo = 92897000 ; $SunInfo = 72000000 ; $MoonInfo = 3456 ; echo "<p>Hello $WorldVar!<br />" ; echo "The $WorldVar is $WorldInfo miles from the $SunVar.<br />"; echo "The $SunVar's core temperature is approximately $SunInfo degrees Fahrenheit. <br />" ; echo "Hello ", $MoonVar, "!<br />" ; echo "The $MoonVar is $MoonInfo miles in diameter.</p>"; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/ Share on other sites More sharing options...
samshel Posted March 4, 2009 Share Posted March 4, 2009 what is it showing? works when i put it in a file and open !! Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775975 Share on other sites More sharing options...
geekette Posted March 4, 2009 Author Share Posted March 4, 2009 what is it showing? works when i put it in a file and open !! This is what I'm seeing: $WorldVar = "World"; $SunVar = "Sun" ; $MoonVar = "Moon" ; $WorldInfo = 92897000 ; $SunInfo = 72000000 ; $MoonInfo = 3456 ; Hello $WorldVar! " ; echo "The $WorldVar is $WorldInfo miles from the $SunVar. "; echo "The $SunVar's core temperature is approximately $SunInfo degrees Fahrenheit. " ; echo "Hello ", $MoonVar, "! " ; echo "The $MoonVar is $MoonInfo miles in diameter."; ?> Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775976 Share on other sites More sharing options...
samshel Posted March 4, 2009 Share Posted March 4, 2009 It is not parsing it as a php file, do u have php installed ? Where r u checking this? if u r checkingo n local machine, u will have to have a web server with php. Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775980 Share on other sites More sharing options...
phpdragon Posted March 4, 2009 Share Posted March 4, 2009 that would be the problem, code works fine for me https://buildfits1.buildfit.com/ausglobal/m.php Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775982 Share on other sites More sharing options...
geekette Posted March 4, 2009 Author Share Posted March 4, 2009 It is not parsing it as a php file, do u have php installed ? Where r u checking this? if u r checkingo n local machine, u will have to have a web server with php. I have php installed as well as apache as my server. Oh wait a minute...I don't think it's turned on..wow, I feel stupid.. Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775984 Share on other sites More sharing options...
samshel Posted March 4, 2009 Share Posted March 4, 2009 if it is not on, u will not see the file at all... i think it is on, how are you accessing the file ? http://localhost/filename.php If u have directly opened the file by double clickling it wont compile PHP. u need to out it in document root of apache and see it as an url as given above. Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775987 Share on other sites More sharing options...
geekette Posted March 4, 2009 Author Share Posted March 4, 2009 No wait, I take that back. It's turned on. I have XAMPP for Macs. And it's still not showing up correctly. I'm accessing the file through Firefox. Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775988 Share on other sites More sharing options...
Yammyguy Posted March 4, 2009 Share Posted March 4, 2009 I wrote the following for a class assignment, but unfortunately, it is not showing up correctly on my browser. I know it's not the browser as I have opened other php documents through it. Any help would be appreciated!..: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Hello World</title> </head> <body> <?php $WorldVar = "World"; $SunVar = "Sun" ; $MoonVar = "Moon" ; $WorldInfo = 92897000 ; $SunInfo = 72000000 ; $MoonInfo = 3456 ; echo "<p>Hello $WorldVar!<br />" ; echo "The $WorldVar is $WorldInfo miles from the $SunVar.<br />"; echo "The $SunVar's core temperature is approximately $SunInfo degrees Fahrenheit. <br />" ; echo "Hello ", $MoonVar, "!<br />" ; echo "The $MoonVar is $MoonInfo miles in diameter.</p>"; ?> </body> </html> Try this: printf('Hello %s! <br />', $WorldVar); printf('The %s\'s core temperature is approximately %s degrees Farenheit. <br />', $SunVar, $SunInfo); printf('Hello %s !<br />', $MoonVar); printf('The %s is %s miles in diameter. </p>', $MoonVar, $MoonInfo); You can use what you had, just remember, if you're putting any " ' " within the quotes, you have to put a \ so the code continues. echo "remember apostrophe\'s need a backslash!"; Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775992 Share on other sites More sharing options...
geekette Posted March 4, 2009 Author Share Posted March 4, 2009 Thanks everyone! And Samshel especially. I didn't open it through http://localhost and that seemed to be the problem. Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775994 Share on other sites More sharing options...
samshel Posted March 4, 2009 Share Posted March 4, 2009 those can be the only reasons u see the PHP code please mark as solved ! Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775995 Share on other sites More sharing options...
geekette Posted March 4, 2009 Author Share Posted March 4, 2009 I just signed up for this forum today. 25 minutes ago to be exact. Excuse my ignorance, but how do I mark this as solved? Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775997 Share on other sites More sharing options...
samshel Posted March 4, 2009 Share Posted March 4, 2009 there should be a checkbox below ur post or check help, i m not sure ! Link to comment https://forums.phpfreaks.com/topic/147844-solved-help-me/#findComment-775999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.