Any PHP programming gurus?

Options
sunrise611
sunrise611 Posts: 1,911 Member
I am trying to do something that should be simple in PHP and it's not working.

I simply want to change a small snippet of code to include line breaks such as <br> or <p> in an outputted email message.

If you know PHP and think you can help, contact me.

Thanks!

Replies

  • _GlaDOS_
    _GlaDOS_ Posts: 1,520 Member
    Options
    Uhhh I’m only pretending to know what I’m talking about here, but I think what you are looking for is either /n or <br />. I believe one is a line break in the code and the other shows a line break in the actual output...

    If I’m right, that would be both excellent and nerdy.
  • dsjohndrow
    dsjohndrow Posts: 1,820 Member
    Options
    If you are printing a line.

    print 'what you want'.'<br />'.'More of what you want.'

    You can concatenate with a dot . i am not sure if you have any dynamic code from a database - but google concatenate if you need to. Text needs quotes. Depending on which version of PHP you need to escape some characters a \. IE: \<br \>
  • Sepheara
    Sepheara Posts: 208 Member
    Options
    \n moves to the next line with PHP
    *edit to add, you can repeat this
    \n
    \n
    \n
    if you want
  • shaj316
    shaj316 Posts: 161
    Options
    Uhhh I’m only pretending to know what I’m talking about here, but I think what you are looking for is either /n or <br />. I believe one is a line break in the code and the other shows a line break in the actual output...

    If I’m right, that would be both excellent and nerdy.

    Uhh...you are using the handle _GlaDOS_. You have therefore already obtained "excellent and nerdy" status.
  • rocketpants
    rocketpants Posts: 419 Member
    Options
    php you can mix html with the code you don't need to do the print
    <?php
    ......
    $message = '
    <html>
    <head>
    <title>hi</title>
    </head>
    <body>
    <p>MFP RULEs!</p>
    this has a line break <br/><br/>
    </body>
    </html>
    ';

    // To send HTML mail, the Content-type header must be set
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Mail it
    mail($to, $subject, $message, $headers);
    ?>

    Jess is correct that proper xhtml requires you to close your br but that is likely not the issue.
    <br/>
  • Sepheara
    Sepheara Posts: 208 Member
    Options
    This is driving me crazy, i am having a brain fart. One of my majors is CS (Computer science) I am trying to remember the proper name of those things.

    cout << "/"" << endl;

    i want to say delimiter but that's not it.

    lol I think we are in the same boat. Instead of highschool I went to a votech and did computer programming and web/graphic design but when I hit the job force all I have landed is hardware jobs and I know this stuff is in my head somewhere. somewhere being the key word.
  • gazz777
    gazz777 Posts: 722
    Options
    Bump !
  • ScatteredThoughts
    ScatteredThoughts Posts: 3,562 Member
    Options
    This is driving me crazy, i am having a brain fart. One of my majors is CS (Computer science) I am trying to remember the proper name of those things.

    cout << "/"" << endl;

    i want to say delimiter but that's not it.

    I/O Redirection?
  • Sepheara
    Sepheara Posts: 208 Member
    Options
    This is driving me crazy, i am having a brain fart. One of my majors is CS (Computer science) I am trying to remember the proper name of those things.

    cout << "/"" << endl;

    i want to say delimiter but that's not it.

    lol I think we are in the same boat. Instead of highschool I went to a votech and did computer programming and web/graphic design but when I hit the job force all I have landed is hardware jobs and I know this stuff is in my head somewhere. somewhere being the key word.

    "ESCAPES!" that's it. it was driving me crazy.

    Yeah i had a computer repair business, I don't like hardware work.

    I liked software but I burn so many more calories lugging servers up and down stairs ;)
  • sunrise611
    sunrise611 Posts: 1,911 Member
    Options
    \n moves to the next line with PHP
    *edit to add, you can repeat this
    \n
    \n
    \n
    if you want

    Thanks. I'll see if I can get that to work.
  • sunrise611
    sunrise611 Posts: 1,911 Member
    Options
    php you can mix html with the code you don't need to do the print
    <?php
    ......
    $message = '
    <html>
    <head>
    <title>hi</title>
    </head>
    <body>
    <p>MFP RULEs!</p>
    this has a line break <br/><br/>
    </body>
    </html>
    ';

    // To send HTML mail, the Content-type header must be set
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Mail it
    mail($to, $subject, $message, $headers);
    ?>

    Jess is correct that proper xhtml requires you to close your br but that is likely not the issue.
    <br/>

    Hi RocketPants, I tried this code and it didn't work. The code that the original programmer used is more complicated and I'm trying to simplify and work within those parameters.

    This is the code:

    $mailMessage = __("Greetings from My Site! You received a new message from", "name")." ".$sendfrom.", ".__("You can read the message at", "name").": ".$this->pageURL;

    I want a line break after "Greetings from My Site!" (Names changed for privacy.)

    It would also be nice to have a line break after "You received a new message from ___."

    I'll try this and see if it works:

    $mailMessage = __("Greetings from My Site! \n \n You received a new message from", "name" \n \n)." ".$sendfrom.", ".__("You can read the message at", "name").": ".$this->pageURL;

    Let me know if you see a problem with this and how you would code it. Thanks!