Jump to content

basic php trouble


geekette

Recommended Posts

  Quote

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

  Quote

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 = 'name@myemail.com' ;
$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

Archived

This topic is now archived and is closed to further replies.

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