Jump to content

Search the Community

Showing results for tags 'extends'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. ckrudelux

    parent::

    <?phpclass test { private $messages = array(); public function addMessage($message){ $this->message[] = $message; } public function getMessages(){ return $this->messages; } } class test2 extends test{ public function getMessages(){ $this->addMessage("Last message."); return parent::getMessages(); }} $test2 = new test2();$test2->addMessage("Hello World");print_r($test2->getMessages()); In my world of understanding this should return an array with 2 entries but I get an empty array back, anyone know what's wrong? What the code does is what class test2 overwrites getMessages and adds a message and calls back to the parent method to do the original script of the function. odd is this work: class test2 extends test{ public function getMessages(){ $this->addMessage("Last message."); return $this->messages; }}
×
×
  • Create New...