Guest User

Untitled

a guest
May 25th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. |--------------------------------------------------------------------------
  5. | 返回类型声明
  6. |--------------------------------------------------------------------------
  7. |
  8. | PHP 7 增加了对返回类型声明的支持。 类似于参数类型声明,返回类型声明指明了函数返回值的类型。可用的类型与参数声明中可用的类型相同。
  9. |
  10. */
  11.  
  12. function reverseString($string) : string
  13. {
  14. return $string;
  15. }
  16.  
  17. echo reverseString('Haven Shen');
  18.  
  19. // Demo
  20.  
  21. interface StorageInterface
  22. {
  23. public function get($key) : string;
  24. }
  25.  
  26. class SessionStorage implements StorageInterface
  27. {
  28. public function get($key) : string
  29. {
  30. return 'string';
  31. }
  32. }
  33.  
  34. $sessionStoreage = new SessionStorage;
  35.  
  36. echo $sessionStoreage->get('test');
Add Comment
Please, Sign In to add comment