Professional Web Applications Themes

2 ways - PHP Development

hi all, Having a session variable test . Is there a difference between: $test = "string"; or $_session['test'] = "string"; kind regards Stijn...

Sponsored Links
  1. #1

    Default 2 ways

    hi all,

    Having a session variable test .

    Is there a difference between:
    $test = "string";
    or
    $_session['test'] = "string";

    kind regards
    Stijn


    Sponsored Links
    Stijn Goris Guest

  2. Moderated Post

    Default Re: 2 ways

    Removed by Administrator
    Steve Guest
    Moderated Post

  3. #3

    Default Re: 2 ways

    Uhm, this looks like assignment to me. A test would be conditional statment
    like if.

    if ( $_SESSION['test'] == 'bigfatbooger') {
    do::some('bathroom');
    }

    = ( Assignment )
    == ( test for equality )

    There is also tests for existance, TRUE/FALSE tests.

    if ($_SESSION['test']) {
    cook::food('pizza');
    } else {
    pig::out('pork rinds');
    }

    Make sense?

    Also, watch your case, no such monster as $_session, its $_SESSION.

    "Stijn Goris" <mepistohotmail.com> wrote in message
    news:3f9d05d2$0$297$ba620e4creader3.news.skynet.b e...
    > hi all,
    >
    > Having a session variable test .
    >
    > Is there a difference between:
    > $test = "string";
    > or
    > $_session['test'] = "string";
    >
    > kind regards
    > Stijn
    >
    >

    Brian Guest

  4. #4

    Default Re: 2 ways

    I think what he means is, does $_SESSION automagically keep track of
    it's member variables and update accordingly.
    The answer is, yes/no/maybe sometimes, it depends on the php version
    and it's config.
    The point I'm trying to make is this... Make sure assignment is ALWAYS
    pointing to exactly what you want to assign.

    Assuming $_SESSION['test'] ==1

    $test = $_SESSION['test'];
    $test ++;

    Will produce one of two results.
    Either $test will now == 2 and $_SESSION['test'] ==2
    Or $test ==2 and $_SESSION['test'] ==1

    It would be best, to have done this instead

    $_SESSION['test'] ++;

    This way we now know for sure it == 2

    By the way, just ignore my first post, it was WAY too early in the
    morning and I was kinda sleepy when I wrote it.


    "Brian" <cpnmscg02 () sneakemail.com> wrote in message news:<zBbnb.41390$Tr4.85919attbi_s03>...
    > Uhm, this looks like assignment to me. A test would be conditional statment
    > like if.
    >
    > if ( $_SESSION['test'] == 'bigfatbooger') {
    > do::some('bathroom');
    > }
    >
    > = ( Assignment )
    > == ( test for equality )
    >
    > There is also tests for existance, TRUE/FALSE tests.
    >
    > if ($_SESSION['test']) {
    > cook::food('pizza');
    > } else {
    > pig::out('pork rinds');
    > }
    >
    > Make sense?
    >
    > Also, watch your case, no such monster as $_session, its $_SESSION.
    >
    > "Stijn Goris" <mepistohotmail.com> wrote in message
    > news:3f9d05d2$0$297$ba620e4creader3.news.skynet.b e...
    > > hi all,
    > >
    > > Having a session variable test .
    > >
    > > Is there a difference between:
    > > $test = "string";
    > > or
    > > $_session['test'] = "string";
    > >
    > > kind regards
    > > Stijn
    > >
    > >
    Steve Guest

Similar Threads

  1. Ways of playing mpg files
    By Flashster in forum Macromedia Director Basics
    Replies: 4
    Last Post: January 25th, 04:20 PM
  2. sort records in both ways
    By Marina in forum ASP.NET Web Services
    Replies: 0
    Last Post: September 25th, 02:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139