a seemingly simple question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
randolph_carter
Forum Newbie
Posts: 3
Joined: Wed Dec 17, 2003 8:15 pm

a seemingly simple question

Post 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
Anthron
Forum Newbie
Posts: 8
Joined: Mon May 20, 2002 6:25 pm
Location: usa
Contact:

Post 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 ;)
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post 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.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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
?>
randolph_carter
Forum Newbie
Posts: 3
Joined: Wed Dec 17, 2003 8:15 pm

a seemingly simple question [fixed]

Post by randolph_carter »

thanks
Post Reply