Jump to content

[SOLVED] Help me!


geekette

Recommended Posts

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

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.