Home > Backend Development > PHP Tutorial > 3 recommended articles about adding functions

3 recommended articles about adding functions

黄舟
Release: 2023-03-09 15:44:02
Original
1008 people have browsed it

During the development process, the return value type of the function should be determined and unchanged, but PHP is a weakly typed language, so PHP does not have such syntax verification. Because of this, it has caused many pitfalls. For example, the following code: The function getArticles returns different types of values ​​according to different conditions, including bool, int, and arrays. Normally, this type of function hopes to return an array, and then use the array to do some other operations, but because the function returns a value The type is not fixed, and various unexpected pitfalls are likely to occur when calling, so I thought that since it cannot be standardized, then just force it. Function/method return values ​​can be forced to type: int function a(){ ... return 1;}bool function b(){ ... return false;}array function c(){ ... ... return array();}object function d(){ ......

1. php: Add function forced type return to php

Introduction: php: Add function mandatory type return to PHP

2. Add function mandatory type return to PHP

3 recommended articles about adding functions

Introduction: During the development process, the return value type of the function should be determined and unchanged, but PHP is a weakly typed language , so PHP does not have such syntax verification, and because of this, it has caused many pitfalls. For example, the following code: ?phpfunction getArticles(...){ $arrData = array(); if($exp1){ return $arrData; }else if($exp2)

3. Time increasing function

3 recommended articles about adding functions

##Introduction: Time increasing function


The above is the detailed content of 3 recommended articles about adding functions. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template