what am I doing wrong

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hougie40@hotmail.com

    #1

    what am I doing wrong

    Im a vb guy trying to figure out some php.

    For some reason it wont let me append these together.

    $variable = "test";

    echo "c:\websites\me nu\" . $variable;

    dont understand...pl ease help.

  • Dikkie Dik

    #2
    Re: what am I doing wrong

    hougie40@hotmai l.com wrote:[color=blue]
    > Im a vb guy trying to figure out some php.
    >
    > For some reason it wont let me append these together.
    >
    > $variable = "test";
    >
    > echo "c:\websites\me nu\" . $variable;
    >
    > dont understand...pl ease help.
    >[/color]
    Is the second quote seen as escaped by the backslash? Maybe it will echo
    "c:\\websites\\ menu\\" . $variable

    Best regards

    Comment

    • Aphrael

      #3
      Re: what am I doing wrong

      hougie40@hotmai l.com a écrit :[color=blue]
      > Im a vb guy trying to figure out some php.
      >
      > For some reason it wont let me append these together.
      >
      > $variable = "test";
      >
      > echo "c:\websites\me nu\" . $variable;
      >
      > dont understand...pl ease help.[/color]

      Ho, you do tell him to consider the final " as a text " instead of the
      end of the string... (\ is the escape caracter...)

      You just need to tell him it is the \ you want to escape... echo
      "c:\websites\me nu\\" . $variable;

      By the way, isn't variable a reserved word ?

      Aphrael...
      --
      "La demande mondiale d'ordinateurs n'excédera pas cinq machines."
      (Thomas Watson, Fondateur d'IBM, 1945)

      Comment

      • Geoff Berrow

        #4
        Re: what am I doing wrong

        I noticed that Message-ID:
        <1127146813.563 664.109190@g43g 2000cwa.googleg roups.com> from
        hougie40@hotmai l.com contained the following:
        [color=blue]
        >$variable = "test";
        >
        >echo "c:\websites\me nu\" . $variable;[/color]

        The backslash is the escape character. For it to be a literal backslash
        you have to escape it with...uh...a backslash.

        echo "c:\\websites\\ menu\\" . $variable;

        Or you could do

        echo "c:\\websites\\ menu\\$variable ";
        --
        Geoff Berrow (put thecat out to email)
        It's only Usenet, no one dies.
        My opinions, not the committee's, mine.
        Simple RFDs http://www.ckdog.co.uk/rfdmaker/

        Comment

        • Paul Herber

          #5
          Re: what am I doing wrong

          On Mon, 19 Sep 2005 17:37:08 +0100, Geoff Berrow
          <blthecat@ckdog .co.uk> wrote:
          [color=blue]
          >I noticed that Message-ID:
          ><1127146813.56 3664.109190@g43 g2000cwa.google groups.com> from
          >hougie40@hotma il.com contained the following:
          >[color=green]
          >>$variable = "test";
          >>
          >>echo "c:\websites\me nu\" . $variable;[/color]
          >
          >The backslash is the escape character. For it to be a literal backslash
          >you have to escape it with...uh...a backslash.
          >
          >echo "c:\\websites\\ menu\\" . $variable;[/color]

          or put a bit less stress on the server

          echo 'c:\websites\me nu\' . $variable;


          --
          Regards, Paul Herber, Sandrila Ltd. http://www.pherber.com/
          SanDriLa - SDL/MSC/TTCN/UML2 application for Visio http://www.sandrila.co.uk/

          Comment

          • Chung Leong

            #6
            Re: what am I doing wrong

            Need to escape backslashes in PHP. Try echo "c:\\websites\\ menu\\" .
            $variable.

            Comment

            • JDS

              #7
              Re: what am I doing wrong

              On Mon, 19 Sep 2005 09:20:13 -0700, hougie40@hotmai l.com wrote:
              [color=blue]
              > For some reason it wont let me append these together.
              >
              > $variable = "test";
              >
              > echo "c:\websites\me nu\" . $variable;
              >
              > dont understand...pl ease help.[/color]

              Blame it on Microsoft

              --
              JDS | jeffrey@example .invalid
              | http://www.newtnotes.com
              DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

              Comment

              • badr

                #8
                Re: what am I doing wrong

                actullay no need for blaming any 1
                the correct way is
                - to escape the last backslash:
                $var="test";

                echo "C:\web\menu\\" .$var;
                ---------------------------------------------
                the optimum solution for the case is :
                $var='test'; //singl qoutes
                echo 'C:\web\menu\\' .$var; //singl qoutes

                ---------------------------------------------
                in double qutes PHP will seek for some varaiable inluded with a string
                so in first solution you may make it like :

                $var="test";

                echo "C:\web\menu\\$ var";

                Comment

                Working...