欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

当我运行下面的脚本,它会输出错误信息,我该怎么_PHP教程

程序员文章站 2022-05-29 11:59:01
...
function myfunc($argument) {
echo $argument + 10;
}
$variable = 10;
echo "myfunc($variable) = " . myfunc($variable);
到底是什么原因呢?
要将自定义函数的结果传回,你需要使用return来将结果传回,而不是echo函数。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632413.htmlTechArticlefunction myfunc($argument) { echo $argument + 10; } $variable = 10; echo "myfunc($variable) = " . myfunc($variable); 到底是什么原因呢? 要将自定义函数的结果传回,...