PHP:如何包含一个类
问题描述:
我有 index.php
我希望在其中加入 class.twitter.php
,我该怎么办这样做?
I have index.php
and I want to include class.twitter.php
inside it, how do I do this?
希望当我把下面的代码放在index.php中时它会起作用。
Hopefully then when I put the below code in index.php it will work.
$t = new twitter();
$t->username = 'user';
$t->password = 'password';
$data = $t->publicTimeline();
答
您的代码应该类似于
require_once('class.twitter.php');
$t = new twitter;
$t->username = 'user';
$t->password = 'password';
$data = $t->publicTimeline();