我想创建这样的函数。请帮我完成我的功能 如果两者都是+ ve
$a = 10;
$b = 6;
// do nothing just show same value 10 and 6
// if $b is negetive
$a = 10;
$b = -3;
// get the value from $a show the value 7 (10 - 3)
// 0 if $a is negative
$a = -2;
$b = 6;
// (little bit diffrent) get the double form $b of negative value and
// show the value 0 and 2(6-4)
我试过这个,但完全停在了其他代码
// $a = something;
// $b = something;
if ($a >0 && $b >0) {
echo $a.' , '.$b;
}else{
// what? what? what?
}
答案 0 :(得分:0)
的内容
<?php
if ($a > 0) {
if ($b > 0) echo $a." ".$b;
else echo ($a+$b)." 0";
}
else {
if ($b > 0) echo "0 ".($b+$a*2);
//else undefined?
}
?>
虽然看起来有点像家常作业