Professional Web Applications Themes

array method attributes (OO) - PHP Development

I wish to pass a session variable into an object and have it available as an attribute. I have what I thought I needed below as a code segment but it douse no work. Has anybody got any idea how I should achieve this. Ben ....... class Contacts{ var $db; array $SESSION; function Contacts( $SESSION, $db ) { $this->$SESSION = $SESSION; $this->$db = $db; } ....... ************************************************** ************** * Ben Edwards Tel +44 (0)1179 553 551 ICQ 42000477 * * Homepage - nothing of interest here [url]http://gurtlush.org.uk[/url] * * Webhosting for the masses [url]http://www.serverone.co.uk[/url] * * Critical Site Builder [url]http://www.criticaldistribution.com[/url] ...

  1. #1

    Default array method attributes (OO)

    I wish to pass a session variable into an object and have it available as
    an attribute. I have what I thought I needed below as a code segment but
    it douse no work. Has anybody got any idea how I should achieve this.

    Ben

    .......

    class Contacts{

    var $db;
    array $SESSION;

    function Contacts( $SESSION, $db ) {

    $this->$SESSION = $SESSION;
    $this->$db = $db;

    }

    .......

    ************************************************** **************
    * Ben Edwards Tel +44 (0)1179 553 551 ICQ 42000477 *
    * Homepage - nothing of interest here [url]http://gurtlush.org.uk[/url] *
    * Webhosting for the masses [url]http://www.serverone.co.uk[/url] *
    * Critical Site Builder [url]http://www.criticaldistribution.com[/url] *
    * online collaborative web authoring content management system *
    * Get alt news/views films online [url]http://www.cultureshop.org[/url] *
    * i-Contact Progressive Video [url]http://www.videonetwork.org[/url] *
    * Fun corporate graphics [url]http://www.subvertise.org[/url] *
    * Bristol Indymedia [url]http://bristol.indymedia.org[/url] *
    * Bristol's radical news [url]http://www.bristle.org.uk[/url] *
    ************************************************** **************

    Ben Edwards Guest

  2. #2

    Default Re: [PHP] array method attributes (OO)

    Hello,

    This is a reply to an e-mail that you wrote on Fri, 8 Aug 2003 at
    14:18, lines prefixed by '>' were originally written by you.
    > I wish to pass a session variable into an object and have it
    available
    > as
    > an attribute. I have what I thought I needed below as a code
    segment
    > but
    > it douse no work. Has anybody got any idea how I should achieve
    this.
    > Ben
    > .......
    > class Contacts{
    > var $db;
    > array $SESSION;
    > function Contacts( $SESSION, $db ) {
    > $this->$SESSION = $SESSION;
    > $this->$db = $db;
    > }
    That will work fine for reading from the variable, are you wanting to
    write to it and have the changes made available outside of your
    class? if so pass the array in by reference...
    function Contacts( &$SESSION, $db )

    HTH,

    David.

    --
    phpmachine :: The quick and easy to use service providing you with
    professionally developed PHP scripts :: [url]http://www.phpmachine.com/[/url]
    Free PHP error handling script: [url]www.phpmachine.com/error-handler/[/url]

    Professional Web Development by David Nicholson
    [url]http://www.djnicholson.com/[/url]

    QuizSender.com - How well do your friends actually know you?
    [url]http://www.quizsender.com/[/url]
    David Nicholson Guest

Similar Threads

  1. Web Service Array method
    By cwbp17 in forum ASP.NET Web Services
    Replies: 0
    Last Post: August 5th, 03:10 PM
  2. #25973 [Fbk->NoF]: object attributes & array mix up
    By sniper@php.net in forum PHP Development
    Replies: 0
    Last Post: November 5th, 05:35 AM
  3. #25973 [Opn->Fbk]: object attributes & array mix up
    By sniper@php.net in forum PHP Development
    Replies: 0
    Last Post: October 31st, 01:58 AM
  4. #25973 [NEW]: object attributes & array mix up
    By mike dot blamires at kingston-callcentres dot co dot uk in forum PHP Development
    Replies: 0
    Last Post: October 24th, 08:24 AM
  5. [PHP] array method attributes (OO)
    By David Nicholson in forum PHP Development
    Replies: 0
    Last Post: August 8th, 03:14 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