Variables

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

    Variables

    Hello,

    I asked this question before (sorry) but I forgot/ran into some problems.

    There are more ways to defina an variable:

    1. $var = 'value'; Notice the '
    2. $var = "value"; Notice the "

    and what is the third? Something like /"value/" I think...
    Thank you.
  • Ken Robinson

    #2
    Re: Variables

    CyberDog wrote (in part):[color=blue]
    > There are more ways to defina an variable:
    >
    > 1. $var = 'value'; Notice the '
    > 2. $var = "value"; Notice the "[/color]

    Did you look in <http://www.php.net/variables>?

    Ken

    Comment

    • Alvaro G Vicario

      #3
      Re: Variables

      *** CyberDog wrote/escribió (Thu, 09 Jun 2005 14:58:34 +0200):[color=blue]
      > There are more ways to defina an variable:
      >
      > 1. $var = 'value'; Notice the '
      > 2. $var = "value"; Notice the "
      >
      > and what is the third? Something like /"value/" I think...[/color]

      As far as I know there're only two ways to define a variable: the =
      operator and functions that receive arguments by reference and modify
      arguments:

      $var='value';

      and

      function asign_value(&$f oo){
      $foo='value';
      }
      asign_value($va r);

      If you mean constants, you use the define() function:

      define('FOO', 'value');
      echo FOO;

      And if you're talking about strings, you need to consider single quotes,
      double quotes and dot (concatenation operator). Double quotes make PHP
      perform variable parsing in strings.


      --
      -- Álvaro G. Vicario - Burgos, Spain
      -- http://bits.demogracia.com - Mi sitio sobre programación web
      -- Don't e-mail me your questions, post them to the group
      --

      Comment

      • CyberDog

        #4
        Re: Variables

        Alvaro G Vicario wrote:[color=blue]
        > As far as I know there're only two ways to define a variable: the =
        > operator and functions that receive arguments by reference and modify
        > arguments:
        >
        > $var='value';
        >
        > and
        >
        > function asign_value(&$f oo){
        > $foo='value';
        > }
        > asign_value($va r);
        >
        > If you mean constants, you use the define() function:
        >
        > define('FOO', 'value');
        > echo FOO;
        >[/color]

        Thank you, I learnedquite a fiew things now, but not what I was trying
        to learn...

        To elaborate my question a little further:

        I have an variable that echoes to the screen at the end of the page.
        I have some dynamicly assigned simple HTML code procesed in the script.
        That simple HTML contains a java script and some links... but java
        script piece of code containd both " and ' within.

        How do I put data that contains both ' and " into a variable $var?

        Comment

        • CyberDog

          #5
          Re: Variables

          Ken Robinson wrote:[color=blue]
          >
          > Did you look in <http://www.php.net/variables>?
          >
          > Ken
          >[/color]

          Thanks for the hint.... I'd never touhgt of that...

          PHP.net mirror in my county is currently down, that's why I posted here,
          I know it's a silly question but I'm kinda in a rush ;)

          Comment

          • Daniel Tryba

            #6
            Re: Variables

            CyberDog <n/a@n/a.com> wrote:[color=blue]
            > I have an variable that echoes to the screen at the end of the page.
            > I have some dynamicly assigned simple HTML code procesed in the script.
            > That simple HTML contains a java script and some links... but java
            > script piece of code containd both " and ' within.
            >
            > How do I put data that contains both ' and " into a variable $var?[/color]

            It's all in the fine manual, so please read the thing:


            Comment

            • Alvaro G Vicario

              #7
              Re: Variables

              *** CyberDog wrote/escribió (Thu, 09 Jun 2005 19:14:01 +0200):[color=blue]
              > PHP.net mirror in my county is currently down, that's why I posted here,[/color]

              That's the purpose of mirrors: if one is down, you switch to another one.


              --
              -- Álvaro G. Vicario - Burgos, Spain
              -- http://bits.demogracia.com - Mi sitio sobre programación web
              -- Don't e-mail me your questions, post them to the group
              --

              Comment

              • pwiegers@gmail.com

                #8
                Re: Variables

                $var<<<EOF
                bla baql 'b'a
                "bla"
                EOF

                greets,

                Paul

                Comment

                • CyberDog

                  #9
                  Re: Variables

                  pwiegers@gmail. com wrote:[color=blue]
                  > $var<<<EOF
                  > bla baql 'b'a
                  > "bla"
                  > EOF
                  >
                  > greets,
                  >
                  > Paul[/color]

                  Thank you, I will find much use for it in the future, in the meantime I
                  used $var= 'bla "bla" /'bla/' ' ect.

                  Comment

                  • CyberDog

                    #10
                    Re: Variables

                    Alvaro G Vicario wrote:[color=blue]
                    > That's the purpose of mirrors: if one is down, you switch to another one.[/color]

                    Can't, www.php.net redirects to an service unavaible page.

                    Comment

                    • Alvaro G Vicario

                      #11
                      Re: Variables

                      *** CyberDog wrote/escribió (Fri, 10 Jun 2005 10:51:31 +0200):[color=blue]
                      > Alvaro G Vicario wrote:[color=green]
                      >> That's the purpose of mirrors: if one is down, you switch to another one.[/color]
                      >
                      > Can't, www.php.net redirects to an service unavaible page.[/color]

                      Try going to main page and then clicking on "Mirror sites" on bottom bar. I
                      only get redirected to mirrors when I perform searches.


                      --
                      -- Álvaro G. Vicario - Burgos, Spain
                      -- http://bits.demogracia.com - Mi sitio sobre programación web
                      -- Don't e-mail me your questions, post them to the group
                      --

                      Comment

                      • Ken Robinson

                        #12
                        Re: Variables



                        CyberDog wrote:[color=blue]
                        > pwiegers@gmail. com wrote:[color=green]
                        > > $var<<<EOF
                        > > bla baql 'b'a
                        > > "bla"
                        > > EOF
                        > >
                        > > greets,
                        > >
                        > > Paul[/color]
                        >
                        > Thank you, I will find much use for it in the future, in the meantime I
                        > used $var= 'bla "bla" /'bla/' ' ect.[/color]

                        You can also do:

                        $var = 'bla "bla" '. "'bla'";

                        I have a strong dislike for escaping quotes since it makes the lines so
                        hard to read.

                        Ken

                        Comment

                        • Chung Leong

                          #13
                          Re: Variables

                          There's also extract().

                          Comment

                          Working...