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?
Remove the $
sign at $return
.
function countdown($month, $day, $year)
{
return ceil( ( mktime( 0,0,0,$month,$day,$year ) - time() ) / 86400 );
}
精彩评论