background image

{

return

 json_decode(

$this

->curl(''.

$url

));

}
}

/** Facebook API Class */
class

 Facebook_API

{

use

 cURL; 

// and here

public

 

function

 get(

$url

)

{

return

 json_decode(

$this

->curl(''.

$url

));

}
}

$facebook

 = 

new

 Facebook_API();

echo

 

$facebook

->get('500058753')->name; 

// Rasmus Lerdorf

/** Now demonstrating the awesomeness of PHP 5.4 syntax */

echo

 (

new

 Facebook_API)->get('500058753')->name;

$foo

 = 'get';

echo

 (

new

 Facebook_API)->

$foo

('500058753')->name;

echo

 (

new

 Twitter_API)->get('1/users/show.json?screen_name=rasmus')->name;

 
看明白了吗

?没有?那你来瞅瞅更简单的例子

代码如下

:

 
trait Hello
{

public

 

function

 hello()

{

return

 'Hello';

}
}
trait Cichui
{

public

 

function

 cichui()

{

return

 ' cichui';

}
}

class

 HelloCichui

{

use

 Hello, Cichui;

public

 

function

 the_end()

{

return

 '!';