xxreenaxx1 Posted January 29, 2011 Share Posted January 29, 2011 Hey, I tired to run this. It so simple but I don't know whats wrong with it <HEAD> <TITLE>Welcome</TITLE> </HEAD> <BODY> <P>Hi, <?php $firstname = 'Ragena'; echo '$firstname'; // PHP finishes here, now back to HTML ?> Your first name is <?php echo $firstname; ?>.</P> <P>The time now is <?php echo date(‘Y-m-d H: -- i:s’); ?></P> </BODY> </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/226055-why-wont-this-simple-code-work/ Share on other sites More sharing options...
tommr Posted January 29, 2011 Share Posted January 29, 2011 Try this... And get a better date snippet. and start <?php on the beginning of the line. <HEAD> <TITLE>Welcome</TITLE> </HEAD> <BODY> <P>Hi, <?php $firstname = 'Ragena'; // PHP finishes here, now back to HTML ?> Your first name is <?php echo $firstname; ?>. </P> </BODY> </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/226055-why-wont-this-simple-code-work/#findComment-1166979 Share on other sites More sharing options...
xxreenaxx1 Posted January 29, 2011 Author Share Posted January 29, 2011 Nope doesn't work. The name wont display. Quote Link to comment https://forums.phpfreaks.com/topic/226055-why-wont-this-simple-code-work/#findComment-1166989 Share on other sites More sharing options...
.josh Posted January 29, 2011 Share Posted January 29, 2011 echo '$firstname'; You need to either use double quotes "..." or no quotes. Variables are not evaluated in single quotes. date(‘Y-m-d H: -- i:s’) You can't use those funky quotes. PHP recognizes normal single or double quotes '...' or "..." Also in the future, try to be more descriptive of the problem. Explain what you expect to be happening and what it is not doing that you expect. Explain what it is doing instead. Just saying "It doesn't work" is not descriptive. Everything else is syntactically correct. Quote Link to comment https://forums.phpfreaks.com/topic/226055-why-wont-this-simple-code-work/#findComment-1166991 Share on other sites More sharing options...
PaulRyan Posted January 29, 2011 Share Posted January 29, 2011 <?php date_default_timezone_set('Europe/London'); ?> <html> <head> <title>Welcome</title> </head> <body> <p>Hi, <?php $firstname = 'Ragena'; echo $firstname; // PHP finishes here, now back to HTML ?> </p> Your first name is <?php echo $firstname; ?>.</p> <p>The time now is <?php echo date('Y-m-d H: -- i:s'); ?></p> </body> </html> Try using the code above, you didn't have proper apostrophes in your code. Also you should use date_default_timezone_set(); as you shold receive a warning if you have display errors on. Regards, PaulRyan. Quote Link to comment https://forums.phpfreaks.com/topic/226055-why-wont-this-simple-code-work/#findComment-1166994 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.