为什么这个简单的代码中没有错误或警告? [英] why is there no error or warning in this simple code ?
本文介绍了为什么这个简单的代码中没有错误或警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么此代码中没有空白屏幕或警告?
当我们使用局部变量 $ result 来显示函数外部的输出时,我想我们在全局使用局部变量范围,必须至少没有输出屏幕或警告。
但这段代码的输出是9.
很抱歉,如果这是一个基本问题,我试过但找不到答案。
<?php
函数add($ first,$ second)
{
$ result = $ first + $ second ;
echo $ result ;
}
add(4,5);
?>
任何人都可以澄清?为什么?
解决方案
结果显示函数外部的输出,我想我们在全局范围内使用局部变量,必须有 - 至少没有输出屏幕或警告。
但这段代码的输出是9.
很抱歉,如果这是一个基本问题,我试过但找不到答案。
<?php
function add(
first,
second)
{
why is there no blank screen or a warning in this code ?
When we use a local variable $result to display the output outside the function, I think we are using a local variable in the global scope and there must be at-least a no output screen or a warning.
But the output for this code is 9.
Sorry if this is a basic question, I tried but couldn't find an answer.
<?php
function add ($first, $second)
{
$result = $first + $second;
echo $result ;
}
add(4,5) ;
?>
Can anyone clarify ? Why ?
解决方案
result to display the output outside the function, I think we are using a local variable in the global scope and there must be at-least a no output screen or a warning.
But the output for this code is 9.
Sorry if this is a basic question, I tried but couldn't find an answer.
<?php function add (
first,
second) {
这篇关于为什么这个简单的代码中没有错误或警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文