"Name the method undefined", but I know that it exists
This line of code:
echo "<strong> {$this->author->last} {$this->date->shortYear()}</strong> ...";
gives me this error:
Fatal error: Call to undefined method Date::shortYear() in /f5/debate/public/libs/Card.php on line 22
Even if in Date.php (which is included in Card.php):
class Date {
public $day;
public $month;
public $year;
public function shortYear() {
return substr($this->year, -2);
}
}
there is a Date class in php. Therefore, I assume that you are creating an invalid Date class.
Change the name of the Date class in Card.php to say myDate;
Then try again $ this-> date = new myDate;
See how it works.
Create a separate verification file to remove any other things that might cause confusion.
DC
Ignoring charles of unnecessary downvote
- Card.php Date
function __construct() {
echo "created date object\n";
}
, , , Date.
, ,
$this->date = new Date;
var_dump($this->date);
differnt, , Date
, , $this- > date -
.
$this->date = new Date;
....
$this->date = new DateTime;
DC