dukevin
dukevin

Reputation: 23178

PHP: Passing variables into a function (classes)

function countdown($month, $day, $year)
{
    return ceil( ( mktime( 0,0,0,$month,$day,$year ) - time() ) / 86400 );
}
class dates
{
    public $month;
    public $day;
    public $year;
}
$exp = new dates;

echo countdown($exp->month, $exp->day, $exp->year);

*Parse error: syntax error, unexpected T_STRING in /var/www/pfn/*

Just learning php, trying to use a php class as a C struct, but for some reason, I can't pass the variables into the function, why is this?

Upvotes: 0

Views: 104

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94625

Remove the $ sign at $return.

function countdown($month, $day, $year)
{
    return ceil( ( mktime( 0,0,0,$month,$day,$year ) - time() ) / 86400 );
}

Upvotes: 3

Related Questions