当我将此代码放在一个函数中(在functions.php 中)并在我的索引文件中回显它时,它不起作用。
<?php
//functions.php
include_once 'sdk/src/facebook.php';
function FB_GetProfilePic($user) {
$fql = "SELECT pic_big FROM profile WHERE id = $user";
$param = array(
'method' => 'fql.query',
'query' => $fql
);
$fqlResult = $facebook->api($param);
return $fqlResult[0]['pic_big'];
}
?>
但是当我在索引文件中执行此操作时,它可以工作。
<?php
//index.php
$fql = "SELECT pic_big FROM profile WHERE id = $user";
$param = array(
'method' => 'fql.query',
'query' => $fql
);
$fqlResult = $facebook->api($param);
echo $fqlResult[0]['pic_big'];
} ?>