在if中分配变量 [英] Assigning variables in if's

查看:92
本文介绍了在if中分配变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


In while(false!==($ file = readdir($ handle)))


会发生什么?

分配$文件,并将其值与false进行比较?

将分配与false进行比较


说,我想返回true或错误代码。我可以吗;


if($ err = somefunc())

echook

else

echo"错误:$ err";


WBR

Sonnich

Hi!

In while (false !== ($file = readdir($handle)))

what happens?
The $file gets assigned, and the value of that is compared with false?
The assignment is being compared with false

Say, I want to return true or an error code. Can I do;

if($err = somefunc())
echo "ok"
else
echo "error: $err";

WBR
Sonnich

推荐答案

file = readdir(
file = readdir(


handle)))


会发生什么?

handle)))

what happens?
The


文件被分配,并且将其值与false进行比较?

将该赋值与false进行比较


说,我想返回true或错误代码。我可以吗;


if(
file gets assigned, and the value of that is compared with false?
The assignment is being compared with false

Say, I want to return true or an error code. Can I do;

if(


这篇关于在if中分配变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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