geekette Posted July 2, 2009 Share Posted July 2, 2009 Hi, I'm having trouble with the following code. Could someone please let me know what I'm doing wrong? Thanks! <?php $email = '[email protected]' ; $name = 'First Last' ; echo "My email address is $email \n My name is $name" ; ?> Link to comment https://forums.phpfreaks.com/topic/164482-basic-php-trouble/ Share on other sites More sharing options...
Bendude14 Posted July 2, 2009 Share Posted July 2, 2009 what troubles are you having the code is ok.. are you running the code on a web server ? Link to comment https://forums.phpfreaks.com/topic/164482-basic-php-trouble/#findComment-867644 Share on other sites More sharing options...
geekette Posted July 2, 2009 Author Share Posted July 2, 2009 opps..i should have been more specific..sorry, it's late. How do i break the 2 lines? shouldn't \n break the echo statements? Link to comment https://forums.phpfreaks.com/topic/164482-basic-php-trouble/#findComment-867646 Share on other sites More sharing options...
Prismatic Posted July 2, 2009 Share Posted July 2, 2009 opps..i should have been more specific..sorry, it's late. How do i break the 2 lines? shouldn't \n break the echo statements? In a terminal, yes it will. It will also break it if you view the source code on a web page. However, it's meaningless rendered. <br /> will break it Link to comment https://forums.phpfreaks.com/topic/164482-basic-php-trouble/#findComment-867649 Share on other sites More sharing options...
geekette Posted July 2, 2009 Author Share Posted July 2, 2009 i'm trying to do it without using <br /> so no idea why \n won't work. Meh, I'll ask the instructor. Thanks anyways! Link to comment https://forums.phpfreaks.com/topic/164482-basic-php-trouble/#findComment-867654 Share on other sites More sharing options...
trq Posted July 2, 2009 Share Posted July 2, 2009 i'm trying to do it without using <br /> so no idea why \n won't work. Meh, I'll ask the instructor. Thanks anyways! html doesn't understand a linebreak. Thats what <br> is for. Assuming you've been asked to do this without using <br> in your code you could use.... <?php $email = '[email protected]' ; $name = 'First Last' ; echo nl2br("My email address is $email \n My name is $name"); ?> nl2br simply add <br> tags where linebreaks are. Link to comment https://forums.phpfreaks.com/topic/164482-basic-php-trouble/#findComment-867656 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.