Return a value from a function:
<?php
function add1($x) {
return $x + 1;
}
echo "5 + 1 is " . add1(5);
?>
Try it Yourself »
The return
keyword ends a function and, optionally, uses the result of an expression as the return value of the function.
If return
is used outside of a function, it stops PHP code in the file from running. If the file was included using include
, include_once
, require
or require_once
, the result of the expression is used as the return value of the include statements.
Learn more functions in our PHP Functions Tutorial.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!