note 118279 deleted from functions.user-defined by cmb

From: Date: Sat, 18 May 2019 07:57:17 +0000
Subject: note 118279 deleted from functions.user-defined by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211057@lists.php.net to get a copy of this message
Note Submitter: ohcc at 163 dot com ---- As of PHP 7.0, you can restrain type of return value of user defined functions. Syntax is : function FunctionName ($arg1, $arg2, ...) : TYPE { ... } TYPE is a string representing the type of return value, TYPE can be a class name or a php variable type, such as array/string/bool/int/float. When TYPE is one of the following value, it also stands for a classname str/boolean/integer/real/double/resource/object/scalar However,in my opion, boolean/bool, integer/int ... should have the same meaning, but at least in PHP7, they stand for different meanings respectively. This may be fixed in later versions of PHP. <?php function wxc ($var) : string { return $var; } ?> this function must return a string, if it return something else when called, a "Fatal error: Uncaught TypeError" error will be triggered. code above is supported only in PHP 7+

« previous php.notes (#211057) next »