Page 1 of 1

a seemingly simple question

Posted: Wed Dec 17, 2003 8:15 pm
by randolph_carter
Hello,
I am pretty new at php coding and have been going on trying to learn from the book, "PHP and MySQL for Web Development." I, so far have installed PHP on my machine and am running it through Apache and have it configured for development on the localhost. So far the example that I have tried:

Code: Select all

<?php
echo ('<p>hello</p>');
echo date('H:i, jS F');
?>
has yielded the output:

hello
"); echo date('H:i, jS F'); ?>

which by no means can be correct (i.e. the extraneous ' ") echo date('H:i, jS F'); ?> '

which should only read

hello [the date]

Am I missing something?

Any suggestions and help would be duly appreciated,

Thanks

Posted: Wed Dec 17, 2003 8:31 pm
by Anthron
that sounded a bit odd to me, so i just copied your code and tried it on my machine:

[qoute]hello
21:29, 17th December[/qoute[

using php 4.3.4

You, however, don't need the () for the echo function.

echo '<p>Hello</p>';
echo date('H:i, jS F');

will work just as well, and who knows, might solve your problem ;)

Posted: Wed Dec 17, 2003 8:31 pm
by DuFF
Are you sure that the example shown is exactly how it is written in the script you are testing? Judging by what printed out:

hello
"); echo date('H:i, jS F'); ?>

My guess is that you have a small error and the script right now looks like this:

Code: Select all

<?php
echo ('<p>hello</p>");  // NOTE: You opened with a ' but ended with a "
echo date('H:i, jS F');
?>
You must open and close a string with the same quotation mark.

Posted: Wed Dec 17, 2003 8:56 pm
by dull1554
sorry doff, but he did open it and close it with a single quote, but i see that there is a double quote in the output carter gave us....i'm sonfused.....where did that come from?, but randolph_carter you really do not need to do this

Code: Select all

<?php
echo ('<p>hello</p>');
echo date('H:i, jS F');
?> 
//do this
<?php
echo "<p>hello</p>";//got rid of the brackets
echo date('H:i, jS F');//no change needed here
?>

a seemingly simple question [fixed]

Posted: Thu Dec 18, 2003 1:46 pm
by randolph_carter
thanks