Why is it that this code prints "Hello!" four times and then prints "1":
<?php
for ($i=1 AND $blah=1; $i<5; $i++) echo("Hello!");
echo($blah);
?>
While this doesn't print out "Hello!" at all and then prints "1":
<?php
for ($i=1 && $blah=1; $i<5; $i++) echo("Hello!");
echo($blah);
?>
I know AND and && have different precedences, but...
Hi all! I'm having a hard time writing up what seems should be a simple if statement! I need it to say if mod does not equal a, b, or c - then do this. Here is what I was trying but have been unsuccessful:
var mod = CURRENT_MODULE_ID;
if (mod != "5827289" && mod != "5195103" && mod != "5181422") {
doSomething();
}
When I type this ...
What's the opposite of triple equals matching in PHP?
$mail_01 = filter_var($mail_01, FILTER_VALIDATE_EMAIL);
if($mail !== false){
echo "Email address required";
}
Is the !== usage correct?
Thanks for any help.
...
This is the only place I've ever seen and, or and not listed as actual operators in C++. When I wrote up a test program in NetBeans, I got the red underlining as if there was a syntax error and figured the website was wrong, but it is NetBeans which is wrong because it compiled and ran as expected.
I can see ! being favored over not but...
I have the following code which redirect pages depends on $path.
...
$path = $this->uri->segment(3);
$pathid = $this->uri->segment(4);
if($path=='forsiden'){
redirect('','refresh');
}elseif($path =='contact'){
redirect('welcome/kontakt','refresh');
}elseif($path =='illustration'){
$thi...
Here is some example data:
data = data.frame(series = c("1a", "1b", "1e"), reading = c(0.1, 0.4, 0.6))
> data
series reading
1 1a 0.1
2 1b 0.4
3 1e 0.6
Which I can pull out selective single rows using subset:
> subset (data, series == "1a")
series reading
1 1a 0.1
And pull out multiple rows usin...
Hi,
I was asked to perform this operation of ternary operator use:
$test='one';
echo $test == 'one' ? 'one' : $test == 'two' ? 'two' : 'three';
Which prints two (checked using php).
I am still not sure about the logic for this. Please, can anybody tell me the logic for this.
...
Hi everyone,
Quick question here about short-circuiting statements in C#. With an if statement like this:
if (MyObject.MyArray.Count == 0 || MyObject.MyArray[0].SomeValue == 0)
{
//....
}
Is it guaranteed that evaluation will stop after the "MyArray.Count" portion, provided that portion is true? Otherwise I'll get a null exception...
Which one out of the following two should be preferred while doing && operation on two values.
if (!StartTime.Equals(DateTime.MinValue) &&
!CreationTime.Equals(DateTime.MinValue))
Or
if (!(StartTime.Equals(DateTime.MinValue) && CreationTime.Equals(DateTime.MinValue))
What is the difference between the two?
...
Is it possible to use together any way operator ?? and operator && in next case:
bool? Any
{
get
{
var any = this.ViewState["any"] as bool?;
return any.HasValue ? any.Value && this.SomeBool : any;
}
}
This means next:
if any is null then this.Any.HasValue return false
if any has value, then it returns value cons...
Hi
$var1 = 22;
$var2 = 10;
echo $var1 = ($var1 < $var2) ? $var1 : $var2; //smaller var
echo '<br />';
echo $var2 = ($var1 > $var2) ? $var1 : $var2; //greater var
I expect it to print 10 and 22 but it prints 10 and 10. any ideas what I am doing wrong?
Thanks
UPDATE
Thanks all.
$min = min($var1, $var2);
$...
I was just wondering if there is an XOR logical operator in C (something like && for AND but for XOR). I know I can split an XOR into ANDs, NOTs and ORs but a simple XOR would be much better. Then it occurred to me that if I use the normal XOR bitwise operator between two conditions, it might just work. And for my tests it did.
Consider...
Hello All,
I am trying to develop a complex textual search engine.
I have thousands of textual pages from many books.
I need to search pages that contain specified complex logical criterias.
These criterias can contain virtually any compination of the following:
A: Full words.
B: Word roots (semilar to stems; i.e. all words with certa...
hi,
how does this execute:
def f(x):
return x>0 and (x%2)+f(x/2) or 0
x is an array ,for instanse,[1, 1, 1, 3]
thank u
...
Possible Duplicate:
Javascript === vs == : Does it matter which equal operator I use?
As the title states; when should you use the === operator check when using JavaScript, and when not to.
Edit: more complete answer found here. Thanks to Mark Byers for pointing it out.
_L
...
Is there a better way to write the following conditional in javascript?
if ( value == 1 || value == 16 || value == -500 || value == 42.42 || value == 'something' ) {
// blah blah blah
}
I hate having all of those logical ORs strung together. I'm wondering if there is some kind of shorthand.
Thanks!
...
Possible Duplicate:
What is the diffference between the | and || or operators?
Logical AND and OR:
(x & y)
(x | y)
Conditional AND and OR:
(x && y)
(x || y)
I've only known about conditional operands up to this point. I know what it does and how to apply it in if-statements. But what is the purpose of logical operands?
...
Hi there,
I know that in Javascript you can do:
var oneOrTheOther = someOtherVar || "these are not the droids you are looking for...move along";
where the variable oneOrTheOther will take on the value of the first expression if it is not null, undefined, or false. In which case it gets assigned to the value of the second statement.
...
Sorry if this is a "Logical Operators 101" kind of question. I've been staring at my screen for 15 minutes trying to wrap my head around it, but I'm stuck.
Is there a more concise/elegant way to phrase the following (this is JavaScript syntax, but it's not a language-dependent question):
if (!something && !something_else) {
// do som...
Possible Duplicate:
Is there any wisdom behind and, or operators in Ruby ?
What is the difference, if any, between the following pairs of logical operators?
&& vs. and
|| vs. or
...