SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: Help with OOPS

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with OOPS

    Hi there
    am not great at OOPS, i do understand it though. I was just wondering if i could make a class this way

    class test(){

    var $temp;
    function initiate(){
    $temp.hour=10;
    $temp.minutes=20;
    $temp.seconds=30;
    $temp.string=array(10,20,30);
    }

    }

    Is it possible to have a variable like temp?

    Thanks
    Vru

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    No it is not.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah okay, can suggest any other similar practices?

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Similar practice of what?
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry for not being clear, some way of having a variable like "temp" in the example i gave. I am trying to program a class with a variable that works like lists in C.

    Thanks
    Vru

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    class test () {

        var 
    $temp = array();

        function 
    test () {

            
    $this->temp['hour']    = 10;
            
    $this->temp['minutes'] = 20;
            
    $this->temp['seconds'] = 30;
            
    $this->temp['string']  = array(102030);

        }

    }

    $t = new test();
    var_dump($t); 
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah okayyyyyy -

    THanks, i will try to see if i can use this method.

    And...how to create dynamic variables with php?

    Thanks
    Vru

  8. #8
    SitePoint Enthusiast bdude's Avatar
    Join Date
    Jan 2006
    Location
    In a house.
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Variables in PHP are inherently dynamic i.e you can define a variable and then later redefine the variable with different information
    SUPPORT FOR NEW BLOGGERS - TRY THE Blogging Forum

  9. #9
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, but what i meant was, i do not know the name of the variable, probably derived from the database.

  10. #10
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)

  11. #11
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    PHP Code:
    class test () { 
    PHP Code:
    //it must be a typo
    class test {... 
    my mobile portal
    ghiris.ro

  12. #12
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks cups, i shall look into it, that's what i was looking for..


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
  •