Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of php return

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

The purpose of this article is to share with you about the usage of php return. I think it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

The use of php return: 1, through the "return expression" way to return an expression result; 2, through the "return (expr)" way to return the function expression; 3, through the return directly return or return null value.

The operating environment of this paper: Windows7 system, PHP7.1, Dell G3.

What is the use of php return?

An Analysis of the usage of return in php

First of all, it means return; return () is a language structure, not a function, and needs to be enclosed in parentheses only if the parameter contains an expression. Parentheses are usually not used when returning a variable, which reduces the burden on PHP.

Basic usage:

A), return expression / / returns an expression result

B), return (expr) / / function expression

C), return / / return directly, or return null

Note: it's best not to use return ($val).

1. If return is executed, the content after the return statement will not be executed

Function add ($a _ r _ r _ b) {return $a _ r _ r _ b; return $a _ r _ r _ b;} $c = add (5j _ 3); / / the resulting $c value can be used elsewhere in the program! Echo $c

Output: 8, only the execution of $astatb is not executed.

2. Return can be a function return value or a null value, depending on the specific usage, for example:

Function test ($a) {if ($a > 10) {return "a > 10";} else {return "a

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report