Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

OOP

I know some php, and instead of installing a vanilla forum on my webspace, i think it would be good exercise to take the script apart and stick it back together on the other end. However, when anyone even mentions Object Oriented stuff, i just get confused. Are there tutorials out thre that are good enough to explain it to someone who doesn't learn too fast?
«1

Comments

  • Options
    I know what you mean, I have lots of problems defining the line where I should use a simple function or create a complex object.

    Just search for it on Google.

    I recomend also checking out SitePoint.com, they have a few nice tutorials about it and also php.net.
  • Options
    I'm reading my PHP and book, and everything makes sense and I just got to the OO section and I'm like :-?.
  • Options
    MarkMark Vanilla Staff
    The hardest part of OOP is coming to terms with how easy it is.
  • Options
    wise words
  • Options
    I really don't know if PHP is the language I'd use to start learning about OOP concepts...
  • Options
    I'm not very interested in any other languages so I'm not going to try to learn them just for OOP.
  • Options
    lechlech Chicagoland
    I really don't know if PHP is the language I'd use to start learning about OOP concepts...

    While it might not be the best language for learning OOP in, it at least makes for good practice in grasping how OOP applies to said language. Then stepping up later into something bigger won't seem as challenging as learning it for the first time again.
  • Options
    Wanna learn OOP by default when learning a language? Well, then you should pick up Ruby. That is what I'm saying, take it home, chew on it.
  • Options
    I was going to suggest that, too.
  • Options
    edited January 2006
    Ok, i'm starting to come to terms with OOP in general but- i'm trying to have a list of tabs, one of which has a class of current_page_item. I'm trying to do this in the following way: // declare a class called Page class Page { // create an array var $activeType = array(); // have a "constructor function" function Page($activeType) { // lots of lines like this: if ($type == 'News') { $this->activeType["News"] = 'class="current_page_item"'; } ; if ($type == 'Events') { $this->activeType["Events"] = 'class="current_page_item"'; } ; ... one for each type .. // and then in a separate function... function addHeader() { $this->page .= <<<EOD // some lines like this <li $this->activeType["News"] ><a href="#">News</a></li> <li $this->activeType["Events"] ><a href="#">Events</a></li> // then outside the class (back in my script) $webPage = new Page('Events'); // finally, display the page echo $webPage->get(); - - - - - - - but then, in my source code i get this <li Array["News"]><a href="#">News</a></li> <li Array["Events"]><a href="#">Events</a></li> - - - - - - - Any ideas why this isn't working? And/or what i can do to make it work?
  • Options
    *suggests smalltalk
  • Options
    MarkMark Vanilla Staff
    shouldn't it be: function Page($type) {
  • Options
    Small enough?
  • Options
    edited January 2006
    "shouldn't it be: function Page($type) {" *slaps self repeatedly* still doesn't work though...
  • Options
    Looks like a syntax problem. I think this:

    <li $this->activeType["News"] ><a href="#">News</a></li>

    is telling PHP to print '<li ', then the value of $this->activeType (cast to a string, which always produces the string 'Array'), and then '["News"]', resulting in:

    <li Array["News"]><a href="#">News</a></li>

    Try putting a curly bracket around the variable, like so:

    <li {$this->activeType["News"]}><a href="#">News</a></li>
  • Options
    ithcyithcy New
    edited January 2006
    wouldn't it be
    <li ${this->activeType["News"]}><a href="#">News</a></li>
    no? okay. i'll get my hat.
  • Options
    nevermind, i'm more used to perl. i guess it works either way in php.

    (if it works either way in perl too, don't tell me, i'll be crushed)
  • Options
    huzzah for curly brackets!
  • Options
    <|:{)

    HOLA!
  • Options
    Is that Santa Claus?
This discussion has been closed.