开发者

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 );
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜