$ i = 0是否相等? [英] Does $i = 0 equal nothing?

查看:75
本文介绍了$ i = 0是否相等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在$ i = 0中,0与0相同或是否为1?


在表单中我有这两个字段 - file file_new 。只有一个(希望)应该包含一个值。我必须确定哪一个有值来确定要执行哪个函数。


[PHP] $ file = mysql_real_escape_string($ _ POST [''file'']);

$ file_new = mysql_real_escape_string($ _ POST [''file_new'']);


$ i = 0;

if($ file > $ i AND $ file_new< $ i)

{

函数文件();

}

else

{

funtion file_new();

} [/ PHP]


我我想我可以放弃if语句的第二部分,除非这有助于我确保只有一个变量包含一个值。如果file_new还包含一个值,我可以返回一条错误消息,说明表格中只能填写其中一个字段。


这是否有效?

或者OR更好: [PHP]

if($ file!=''''AND $ file_new ==''''){

运行此代码

}


if($ file ==''''AND $ file_new!=''''){

运行此代码

}


if($ file!=''''AND $ file_new!='''' '){

运行此代码

}


[/ PHP]


谢谢。

In $i = 0, is 0 the same as nothing or does it count as 1?

In a form I have these two fields - file and file_new. Only one (hopefully) should contain a value. I have to determine which one has a value to determine which function to execute.

[PHP]$file = mysql_real_escape_string($_POST[''file'']);
$file_new = mysql_real_escape_string($_POST[''file_new'']);

$i = 0;
if ($file > $i AND $file_new < $i)
{
function file();
}
else
{
funtion file_new();
}[/PHP]

I guess I could just leave off the second part of the if statement, unless this would help me to make sure that only one variable contains a value. If file_new also contained a value I could return an error message saying that only one of these fields can be filled out on the form.

Will this work or no?

OR is this better: [PHP]
if ($file != '''' AND $file_new == '''') {
run this code
}

if ($file == '''' AND $file_new != '''') {
run this code
}

if ($file != '''' AND $file_new != '''') {
run this code
}

[/PHP]

Thanks.

推荐答案

i = 0,0与0相同或是否为1?


In我有这两个字段的表单 - 文件 file_new 。只有一个(希望)应该包含一个值。我必须确定哪一个有值来确定要执行的函数。


[PHP]
i = 0, is 0 the same as nothing or does it count as 1?

In a form I have these two fields - file and file_new. Only one (hopefully) should contain a value. I have to determine which one has a value to determine which function to execute.

[PHP]


file = mysql_real_escape_string(
file = mysql_real_escape_string(


_POST [''file'']);
_POST[''file'']);


这篇关于$ i = 0是否相等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆