Macro in PHP ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pjotr Wedersteers

    Macro in PHP ?

    Hello,

    I am curious if there is a solution for the following in PHP4:
    I often echo something to my browser during tests. I often forget to add a
    <BR> to the end of the echo command.
    Is it possible to use something like a mcro in C++ to have a command I can
    use like echo but which automatically adds the <br> ?
    Or is there a command that does that for me ?
    Alternatively I could write a function of course, but then brackets come in
    to play as well.

    TIA
    Pjotr


  • Colin McKinnon

    #2
    Re: Macro in PHP ?

    Pjotr Wedersteers wrote:
    [color=blue]
    > Hello,
    >
    > I am curious if there is a solution for the following in PHP4:
    > I often echo something to my browser during tests. I often forget to add a
    > <BR> to the end of the echo command.
    > Is it possible to use something like a mcro in C++ to have a command I can
    > use like echo but which automatically adds the <br> ?
    > Or is there a command that does that for me ?
    > Alternatively I could write a function of course, but then brackets come
    > in to play as well.[/color]

    There are several ways. Easiest would be to use nl2br()

    HTH

    C.

    Comment

    • Pjotr Wedersteers

      #3
      Re: Macro in PHP ?

      Colin McKinnon wrote:[color=blue]
      > Pjotr Wedersteers wrote:
      >[color=green]
      >> Hello,
      >>
      >> I am curious if there is a solution for the following in PHP4:
      >> I often echo something to my browser during tests. I often forget to
      >> add a <BR> to the end of the echo command.
      >> Is it possible to use something like a mcro in C++ to have a command
      >> I can use like echo but which automatically adds the <br> ?
      >> Or is there a command that does that for me ?
      >> Alternatively I could write a function of course, but then brackets
      >> come in to play as well.[/color]
      >
      > There are several ways. Easiest would be to use nl2br()
      >
      > HTH
      >
      > C.[/color]

      Thanks. But this is as "cumbersome " as writing a simple function echobr ();
      I decided to try the following -a constant- for a while. Maybe someone likes
      it or has better ideas.
      Define ("br","<br>" );
      echo "Mystring or whatever".br;
      Another advantage is I can easily change all breaks to newlines and vice
      versa when I am working in my PHP ide, which doesn't display breaks
      properly.
      Pjotr


      Comment

      • Justin Koivisto

        #4
        Re: Macro in PHP ?

        Pjotr Wedersteers wrote:
        [color=blue]
        > Colin McKinnon wrote:
        >[color=green]
        >>Pjotr Wedersteers wrote:
        >>
        >>[color=darkred]
        >>>Hello,
        >>>
        >>>I am curious if there is a solution for the following in PHP4:
        >>>I often echo something to my browser during tests. I often forget to
        >>>add a <BR> to the end of the echo command.
        >>>Is it possible to use something like a mcro in C++ to have a command
        >>>I can use like echo but which automatically adds the <br> ?
        >>>Or is there a command that does that for me ?
        >>>Alternativel y I could write a function of course, but then brackets
        >>>come in to play as well.[/color]
        >>
        >>There are several ways. Easiest would be to use nl2br()
        >>
        >>HTH
        >>
        >>C.[/color]
        >
        >
        > Thanks. But this is as "cumbersome " as writing a simple function echobr ();
        > I decided to try the following -a constant- for a while. Maybe someone likes
        > it or has better ideas.
        > Define ("br","<br>" );
        > echo "Mystring or whatever".br;
        > Another advantage is I can easily change all breaks to newlines and vice
        > versa when I am working in my PHP ide, which doesn't display breaks
        > properly.[/color]

        ....but then you still have to *remember* to put it in... ;)

        --
        Justin Koivisto - spam@koivi.com
        PHP POSTERS: Please use comp.lang.php for PHP related questions,
        alt.php* groups are not recommended.

        Comment

        • Ian.H

          #5
          Re: Macro in PHP ?

          On Tue, 03 Aug 2004 20:22:32 +0200, Pjotr Wedersteers wrote:
          [color=blue]
          > Thanks. But this is as "cumbersome " as writing a simple function echobr ();
          > I decided to try the following -a constant- for a while. Maybe someone likes
          > it or has better ideas.
          > Define ("br","<br>" );
          > echo "Mystring or whatever".br;
          > Another advantage is I can easily change all breaks to newlines and vice
          > versa when I am working in my PHP ide, which doesn't display breaks
          > properly.
          > Pjotr[/color]


          Yikes!

          To me:


          echo 'my string<br />'


          is a lot more simple than having to use concatenation and a constant.. and
          probably uses less resources (no define) although this would obviously be
          too small to physically notice =)

          Using .CONST would be the m$ approach IMO.. "screw standards, I gotz me an
          idea!"



          Regards,

          Ian

          --
          Ian.H
          digiServ Network
          London, UK


          Comment

          • Pjotr Wedersteers

            #6
            Re: Macro in PHP ?

            Ian.H wrote:[color=blue]
            > On Tue, 03 Aug 2004 20:22:32 +0200, Pjotr Wedersteers wrote:
            >[color=green]
            >> Thanks. But this is as "cumbersome " as writing a simple function
            >> echobr (); I decided to try the following -a constant- for a while.
            >> Maybe someone likes it or has better ideas.
            >> Define ("br","<br>" );
            >> echo "Mystring or whatever".br;
            >> Another advantage is I can easily change all breaks to newlines and
            >> vice versa when I am working in my PHP ide, which doesn't display
            >> breaks properly.
            >> Pjotr[/color]
            >
            >
            > Yikes!
            >
            > To me:
            >
            >
            > echo 'my string<br />'
            >
            >
            > is a lot more simple than having to use concatenation and a
            > constant.. and probably uses less resources (no define) although this
            > would obviously be too small to physically notice =)
            >
            > Using .CONST would be the m$ approach IMO.. "screw standards, I gotz
            > me an idea!"
            >
            >[/color]
            Eeek, you say I'm infected with m$ virus.. What's my penance for this sin ?
            But seriously, the problem is mostly when I don't echo strings but numerals,
            without those nasty quotes. I am a lazy typist.
            And echo $a.br; types faster than echo $a."<br />";


            Comment

            • Ian.H

              #7
              Re: Macro in PHP ?

              On Tue, 03 Aug 2004 23:36:24 +0200, Pjotr Wedersteers wrote:
              [color=blue][color=green]
              >> Using .CONST would be the m$ approach IMO.. "screw standards, I gotz
              >> me an idea!"
              >>
              >>[/color]
              > Eeek, you say I'm infected with m$ virus.. What's my penance for this sin ?
              > But seriously, the problem is mostly when I don't echo strings but numerals,
              > without those nasty quotes. I am a lazy typist.
              > And echo $a.br; types faster than echo $a."<br />";[/color]


              Fair play, can see the extra work here (I'm a lazy typist too =) ).

              In Zend, I can hit ctrl+enter and it'll insert a <br> for me.. apologies
              if you've already said, but what editor are you using? I wrote many macros
              for UEdit to add GPL / BSD headers and other small comment snippet inserts
              etc to save myself time.. if your editor has this function it'd be
              a trivial task I'm assuming =)

              Just a thought.



              Regards,

              Ian

              --
              Ian.H
              digiServ Network
              London, UK


              Comment

              Working...