Reputation: 31749
The code below generates the text for the e-mail that is sent when a user requests a new password:
<?php echo __('Your password has been reset, your new login information can be found below:') ?>
Email: <?php echo $sfGuardUser->getEmailAddress().PHP_EOL; ?>
Contraseña: <?php echo $password; ?>
As you can see there are two empty lines between the two first lines of code.
When the email arrives, the empty lines are in the same number as in the .php file. In this case two. I just expected the end of the sentence "Your password.." would be immediately followed by "Email"...
Can someone explain to me why this happens?
Upvotes: 1
Views: 711
Reputation: 73031
PHP only removes line breaks for the open and close tags. In other words, it cleans up for it's own line break, like it were not in your code.
You have line breaks in your email, unrelated to PHP. If you don't want the line breaks, you should do the following:
<?php echo __('Your password has been reset, your new login information can be found below:') ?>
Email: <?php echo $sfGuardUser->getEmailAddress().PHP_EOL; ?>
Contraseña: <?php echo $password; ?>
Notice I removed the line breaks.
Upvotes: 0
Reputation: 24682
<?php
echo __('Your password has been reset, your new login information can be found below:');
echo '\n\n';
echo $sfGuardUser->getEmailAddress().PHP_EOL;
echo '\n';
echo 'Contraseña:' . $password; ?>
Upvotes: 0
Reputation: 175745
Anything outside of <?php ?>
tags will be sent straight to the browser/outputted to the command-line, depending on how you're calling PHP. If you want to avoid emitting them, you need to make them code by including them in the php tag:
<?php echo __('Your password has been reset, your new login information can be found below:')
?>
Email: <?php echo $sfGuardUser->getEmailAddress().PHP_EOL; ?>
Contraseña: <?php echo $password; ?>
Upvotes: 3
Reputation: 4031
Content that's not between < ?php
and ?>
is not modified or collapsed - it passes through the preprocessor unchanged. So, your blank lines are passed straight through to the output.
Upvotes: 1