An dieser Stelle scheint mein Verständniss aufgehört zu haben, ich kann weder die Funktion in der Variable aufrufen - noch die PHP integrierten Funktionen in diesen benutzen.
PHP-Code:
<?php
class Model_Treehouse {
public static function treehouse_get_profile($treehouse_username) {
$json_feed_url = 'http://teamtreehouse.com/' . $treehouse_username . '.json';
$json_feed = file_get_contents($json_feed_url);
$treehouse_profile = json_decode($json_feed);
return $treehouse_profile;
}
/* dosnt work
private static function treehouse_get_profile($treehouse_username) {
$json_feed_url = 'http://teamtreehouse.com/' . $treehouse_username . '.json';
$json_feed = file_get_contents($json_feed_url);
$treehouse_profile = json_decode($json_feed);
}
private static $treehouse_profile = treehouse_get_profile();
*/
/* dosnt work
const $json_feed_url = 'http://teamtreehouse.com/' . $treehouse_username . '.json';
const $json_feed = file_get_contents($json_feed_url);
const $treehouse_profile = json_decode($json_feed);
*/
/* dosnt work
private static $json_feed_url = 'http://teamtreehouse.com/' . $treehouse_username . '.json';
private static $json_feed = file_get_contents($json_feed_url);
private static $treehouse_profile = json_decode($json_feed);
*/
public static function treehouse_badge_all() {
if (!empty(self::$treehouse_profile->badges)) {
return self::$treehouse_profile->badges;
} else {
return null;
}
}
public static function treehouse_badge_id($id) {
if (array_key_exists($id, self::$treehouse_profile->badges)) {
return self::$treehouse_profile->badges[$id];
} else {
return null;
}
}
public static function treehouse_badge_latest($quantity) {
if (count(self::$treehouse_profile->badges) >= $quantity) {
foreach (self::$treehouse->badges as $id=>$value) {
$date[$id] = strtotime($value->earned_date);
}
array_multisort($date, SORT_DESC, self::$treehouse_profile->badges);
return array_slice(self::$treehouse_profile->badges, 0, $quantity);
} else {
return null;
}
}
public static function treehouse_badge_random($quantity) {
if (count(self::$treehouse_profile->badges) >= $quantity) {
return array_rand(self::$treehouse_profile->badges, $quantity);
} else {
return null;
}
}
}
?>
Einen Kommentar schreiben: