Zi 字媒體
2017-07-25T20:27:27+00:00
Return Type Declarations of PHP 7
PHP: 7.2
PHP 7.x 開始提供了一些新的功能,Return Type Declarations 就是其中一種。
Return Type Declarations 可以宣告定義函式中回轉的資料型態,讓函式的結構更為嚴謹。
範例
// 在函式後方利用 : 宣告 return type 為 int
function returnInt($num): int
{
return $num;
}
// 123
echo returnInt(123);
// PHP Fatal error: Uncaught TypeError: Return value of returnInt() must be of the type integer
echo returnInt('String');
Categories: PHP
Tags: PHP
分類
Android
AngularJS
API Blueprint
Chrome
Database
MySQL
DataStructure
Docker
Editor
Vim
Firefox
Git
GitLab
Google API
Hadoop
HTTP
Language
Go
Java
JavaScript
jQuery
jQueryChart
Node.js
Vue
Vue-CLI
PHP
Laravel
Lumen
ZendFramework
Python
Mac
Network
Cisco
DLink
Juniper
Oauth
Server
Apache
Share
Unix
FreeBSD
Linux
WebDesign
Bootstrap
CSS
HTML
Wordpress
Search
搜尋關鍵字:
寫了
5860316篇文章,獲得
23313次喜歡