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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.