如何使用这个php函数?
假设我有这个函数,但我不知道如何调用它如何使用这个php函数?,php,function,Php,Function,假设我有这个函数,但我不知道如何调用它 echo getYoutubeSearchVideosFeeds($variables); 我应该用什么替换$variables来调用$q、$orderby、$startIndex等等 function getYoutubeSearchVideosFeeds($criteria) { $url = 'http://gdata.youtube.com/feeds/api/videos?'; $q = urlencode($criteria[
echo getYoutubeSearchVideosFeeds($variables);
我应该用什么替换$variables来调用$q、$orderby、$startIndex等等
function getYoutubeSearchVideosFeeds($criteria) {
$url = 'http://gdata.youtube.com/feeds/api/videos?';
$q = urlencode($criteria['q']);
$orderby = $criteria['orderby']; // relevance, published, viewCount, rating
$startIndex = $criteria['start-index'];
$maxResults = $criteria['max-results'];
$author = $criteria['author'];
$format = $criteria['format'];
$lr = $criteria['lr']; // fr, en
$safeSearch = $criteria['safeSearch']; //none, moderate, strict
// more code
}
只需将函数中列出的值传递给它一个关联数组:
getYoutubeSearchVideosFeeds(array('q' => '...', 'orderby' => '...', ...));
传递一个数组,数组中填充函数所需的每个键的值:
getYoutubeSearchVideosFeeds(array('q' => '...', 'orderby' => '...'));
这个函数是从哪里来的?
getYoutubeSearchVideosFeeds(
array(
"q"=>"CriteriaValuesHere..GetItFromGDataHelp",
"start-index" => "Other Values"
.
.
.
)
);