Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- |--------------------------------------------------------------------------
- | 返回类型声明
- |--------------------------------------------------------------------------
- |
- | PHP 7 增加了对返回类型声明的支持。 类似于参数类型声明,返回类型声明指明了函数返回值的类型。可用的类型与参数声明中可用的类型相同。
- |
- */
- function reverseString($string) : string
- {
- return $string;
- }
- echo reverseString('Haven Shen');
- // Demo
- interface StorageInterface
- {
- public function get($key) : string;
- }
- class SessionStorage implements StorageInterface
- {
- public function get($key) : string
- {
- return 'string';
- }
- }
- $sessionStoreage = new SessionStorage;
- echo $sessionStoreage->get('test');
Add Comment
Please, Sign In to add comment