FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » AND in the if statement
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
AND in the if statement [message #171234] Wed, 29 December 2010 19:37 Go to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
Ok smart people, answer me this as I have not yet found an answer googling.

if (a=1) echo "hello";

In BASIC, I can say, if a=1 AND b=2 then do this.
Meaning, both conditions MUST be true to get to "do this".


Is it possible to include AND in the PHP if and if so, how?

Maybe like, if (a=1 and b=2) echo "hello";
Re: AND in the if statement [message #171235 is a reply to message #171234] Wed, 29 December 2010 19:42 Go to previous messageGo to next message
Mike is currently offline  Mike
Messages: 18
Registered: December 2010
Karma: 0
Junior Member
Basic... is there (still) such a thing?

if( $a==1 && $b==2) { // do some cool stuff }

If you use a single =, you'll actually set the value and it'll always
be true. the double == checks equality without changing the value.
Use || for OR.

Mike
Re: AND in the if statement [message #171238 is a reply to message #171235] Wed, 29 December 2010 19:55 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Wed, 29 Dec 2010 11:42:41 -0800 (PST), Mike wrote:

> Basic... is there (still) such a thing?
>
> if( $a==1 && $b==2) { // do some cool stuff }
>
> If you use a single =, you'll actually set the value and it'll always
> be true. the double == checks equality without changing the value.
> Use || for OR.
>
> Mike

Finally found a site that describes all the good stuff like that.
http://www.elated.com/articles/php-operators/

I saw one bit of code that showed === and I'm reacting like wtf?
Had not seen that one before. Now I have a resource for that stuff.
Re: AND in the if statement [message #171239 is a reply to message #171234] Wed, 29 December 2010 20:28 Go to previous messageGo to next message
Derek Turner is currently offline  Derek Turner
Messages: 48
Registered: October 2010
Karma: 0
Member
On Wed, 29 Dec 2010 12:37:08 -0700, richard wrote:

> Ok smart people, answer me this as I have not yet found an answer
> googling.
>
> if (a=1) echo "hello";
>
> In BASIC, I can say, if a=1 AND b=2 then do this. Meaning, both
> conditions MUST be true to get to "do this".
>
>
> Is it possible to include AND in the PHP if and if so, how?
>
> Maybe like, if (a=1 and b=2) echo "hello";

rtfm or jfgi
Re: AND in the if statement [message #171241 is a reply to message #171234] Wed, 29 December 2010 20:37 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 29/12/10 19:37, richard wrote:
> Ok smart people, answer me this as I have not yet found an answer googling.
>
> if (a=1) echo "hello";

You haven't been listening.

You have been told what is wrong with this at least twice in the last
two days. You are failing to absorb this essential and fundamental piece
of php.

> In BASIC, I can say, if a=1 AND b=2 then do this.
> Meaning, both conditions MUST be true to get to "do this".

php is not basic. You need to use the correct php syntax and constructs
to do things in php. When you learn the basic php syntaxes and
constructs, people may become more helpful.

> Is it possible to include AND in the PHP if and if so, how?
>
> Maybe like, if (a=1 and b=2) echo "hello";

You say you are familiar with the php.net website, yet you obviously
managed to miss pages referring to control structures, specifically the
use of if, and logical and comparison operators, despite the fact that
they can be found in the clearly labelled control structures and
operators sections of the clearly labelled language reference section of
the clearly labelled manual.

Therefore, for your next lesson, go to the php.net website, find the
manual pages that deal with:

Manual
Language Reference
Operators
Operator Precedence

Manual
Language Reference
Operators
Comparison Operators

Manual
Language Reference
Operators
Logical Operators

Manual
Language Reference
Control Structures
If

Once you have read those pages, you will either know the answer to the
questions that you have asked here, or, if you do not then know the
answers, will instead know that you have no aptitude whatsoever for
programming in php and should find another hobby, probably one that does
not involve computers.

Rgds

Denis McMahon
Re: AND in the if statement [message #171242 is a reply to message #171241] Wed, 29 December 2010 20:51 Go to previous messageGo to next message
Mike is currently offline  Mike
Messages: 18
Registered: December 2010
Karma: 0
Junior Member
Dennis,

What was the point of that? When I started with PHP, I was as
unfamiliar with the jargon and even how to follow the manual pages.
The guy asked a simple question, so either answer his question or stfu.
Re: AND in the if statement [message #171244 is a reply to message #171241] Wed, 29 December 2010 20:53 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Wed, 29 Dec 2010 20:37:05 +0000, Denis McMahon wrote:

> On 29/12/10 19:37, richard wrote:
>> Ok smart people, answer me this as I have not yet found an answer googling.
>>
>> if (a=1) echo "hello";
>
> You haven't been listening.
>
> You have been told what is wrong with this at least twice in the last
> two days. You are failing to absorb this essential and fundamental piece
> of php.
>
>> In BASIC, I can say, if a=1 AND b=2 then do this.
>> Meaning, both conditions MUST be true to get to "do this".
>
> php is not basic. You need to use the correct php syntax and constructs
> to do things in php. When you learn the basic php syntaxes and
> constructs, people may become more helpful.
>
>> Is it possible to include AND in the PHP if and if so, how?
>>
>> Maybe like, if (a=1 and b=2) echo "hello";
>
> You say you are familiar with the php.net website, yet you obviously
> managed to miss pages referring to control structures, specifically the
> use of if, and logical and comparison operators, despite the fact that
> they can be found in the clearly labelled control structures and
> operators sections of the clearly labelled language reference section of
> the clearly labelled manual.
>
> Therefore, for your next lesson, go to the php.net website, find the
> manual pages that deal with:
>
> Manual
> Language Reference
> Operators
> Operator Precedence
>
> Manual
> Language Reference
> Operators
> Comparison Operators
>
> Manual
> Language Reference
> Operators
> Logical Operators
>
> Manual
> Language Reference
> Control Structures
> If
>
> Once you have read those pages, you will either know the answer to the
> questions that you have asked here, or, if you do not then know the
> answers, will instead know that you have no aptitude whatsoever for
> programming in php and should find another hobby, probably one that does
> not involve computers.
>
> Rgds
>
> Denis McMahon

If my syntax is wrong then so is the coding at php.net.
From php.net's example:
<?php
if ($a > $b)
echo "a is bigger than b";
?>

Where I may use a single = operator in a post, it is only to show what I'm
after in the whole.
I understand that it is best to use double == operators in real life.
Re: AND in the if statement [message #171246 is a reply to message #171242] Wed, 29 December 2010 21:03 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Dec 29, 8:51 pm, Mike <mpea...@gmail.com> wrote:
> Dennis,
>
> What was the point of that?  When I started with PHP, I was as
> unfamiliar with the jargon and even how to follow the manual pages.
> The guy asked a simple question, so either answer his question or stfu.

This guy has been posting these same questions for over a year now.

Just how long do you define "started with php". A year is long enough
to understand basic syntax. Also he has posted the same sorts of code
that will never run in php for the past 7 days, despite having loads
of people correct him.

Maybe when he has been working with php for 10 years, you will
consider that he has not "just started"???
Re: AND in the if statement [message #171248 is a reply to message #171244] Wed, 29 December 2010 21:05 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Dec 29, 8:53 pm, richard <mem...@newsguy.com> wrote:
> On Wed, 29 Dec 2010 20:37:05 +0000, Denis McMahon wrote:
>> On 29/12/10 19:37, richard wrote:
>>> Ok smart people, answer me this as I have not yet found an answer googling.
>
>>> if (a=1) echo "hello";
>
>> You haven't been listening.
>
>> You have been told what is wrong with this at least twice in the last
>> two days. You are failing to absorb this essential and fundamental piece
>> of php.
>
>>> In BASIC, I can say, if a=1 AND b=2 then do this.
>>> Meaning, both conditions MUST be true to get to "do this".
>
>> php is not basic. You need to use the correct php syntax and constructs
>> to do things in php. When you learn the basic php syntaxes and
>> constructs, people may become more helpful.
>
>>> Is it possible to include AND in the PHP if and if so, how?
>
>>> Maybe like, if (a=1 and b=2) echo "hello";
>
>> You say you are familiar with the php.net website, yet you obviously
>> managed to miss pages referring to control structures, specifically the
>> use of if, and logical and comparison operators, despite the fact that
>> they can be found in the clearly labelled control structures and
>> operators sections of the clearly labelled language reference section of
>> the clearly labelled manual.
>
>> Therefore, for your next lesson, go to the php.net website, find the
>> manual pages that deal with:
>
>> Manual
>>   Language Reference
>>       Operators
>>         Operator Precedence
>
>> Manual
>>   Language Reference
>>       Operators
>>         Comparison Operators
>
>> Manual
>>   Language Reference
>>       Operators
>>         Logical Operators
>
>> Manual
>>   Language Reference
>>     Control Structures
>>       If
>
>> Once you have read those pages, you will either know the answer to the
>> questions that you have asked here, or, if you do not then know the
>> answers, will instead know that you have no aptitude whatsoever for
>> programming in php and should find another hobby, probably one that does
>> not involve computers.
>
>> Rgds
>
>> Denis McMahon
>
> If my syntax is wrong then so is the coding at php.net.
> From php.net's example:
> <?php
> if ($a > $b)
>   echo "a is bigger than b";
> ?>
>
> Where I may use a single = operator in a post, it is only to show what I'm
> after in the whole.
> I understand that it is best to use double == operators in real life.

Not "best" you idiot. In php = is an assignment operator and == is a
comparison one. They do completely different things.

php.net is not wrong, you are an idiot.
Re: AND in the if statement [message #171249 is a reply to message #171244] Wed, 29 December 2010 21:06 Go to previous messageGo to next message
Derek Turner is currently offline  Derek Turner
Messages: 48
Registered: October 2010
Karma: 0
Member
On Wed, 29 Dec 2010 13:53:30 -0700, richard wrote:

> Where I may use a single = operator in a post, it is only to show what
> I'm after in the whole.
> I understand that it is best to use double == operators in real life.

It's not better YOU THICK CUNT it's essential. You are now plonked as you
are not worth answering. In fact I can only assume that you are a troll.
Re: AND in the if statement [message #171252 is a reply to message #171246] Wed, 29 December 2010 21:08 Go to previous messageGo to next message
Mike is currently offline  Mike
Messages: 18
Registered: December 2010
Karma: 0
Junior Member
I can see your frustration... I hadn't realized that this guy hasn't
taken the time, or perhaps he's using this forum to build in bound
links to the site he referenced. Still, I'm not sure that flaming
really helps matters. My $0.02.

Mike
Re: AND in the if statement [message #171254 is a reply to message #171244] Wed, 29 December 2010 21:14 Go to previous messageGo to next message
Leonardo Azpurua is currently offline  Leonardo Azpurua
Messages: 46
Registered: December 2010
Karma: 0
Member
"richard" <member(at)newsguy(dot)com> escribió en el mensaje
news:1vbfb0a9uj34w$(dot)dlg(at)evanplatt(dot)sux...
> If my syntax is wrong then so is the coding at php.net.
> From php.net's example:
> <?php
> if ($a > $b)
> echo "a is bigger than b";
> ?>
>
> Where I may use a single = operator in a post, it is only to show what I'm
> after in the whole.
> I understand that it is best to use double == operators in real life.

It is not "best". If you want to test for equality, you *must* use either ==
(equality of values) or === (equality of values and of types): (5 == "5") ==
true; (5 === "5") == false; (5 === 5) == true; ("5" = 5) will produce a
syntax error, since you can't assign to a literal value.

The example that you bring from php.net is Ok. Greater than is spelled >.But
equal is spelled == or ===. On the other hand, >> is the right shift
operator.

If you really want to learn, you should be humble enough to know where you
are mistaken, instead of trying to hold your position regardless of how
wrong you are.

Denis' post is the best advice that you can get at this point. Go RTFM.

--
Re: AND in the if statement [message #171255 is a reply to message #171242] Wed, 29 December 2010 21:24 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
Mike wrote:

> Dennis,
>
> What was the point of that? When I started with PHP, I was as
> unfamiliar with the jargon and even how to follow the manual pages.
> The guy asked a simple question, so either answer his question or
> stfu.

You are apparently unfamiliar with richard... :-)

--
-bts
-Four wheels carry the body; two wheels move the soul
Re: AND in the if statement [message #171257 is a reply to message #171244] Wed, 29 December 2010 21:25 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
richard wrote:

> If my syntax is wrong then so is the coding at php.net.
> From php.net's example:
> <?php
> if ($a > $b)
> echo "a is bigger than b";
> ?>

That is not wrong. Why would you even suggest it?

> Where I may use a single = operator in a post, it is only to show what
> I'm after in the whole.

You can't do that.

> I understand that it is best to use double == operators in real life.

It is not "best" to use == when you want to compare; it is "required."

--
-bts
-Four wheels carry the body; two wheels move the soul
Re: AND in the if statement [message #171260 is a reply to message #171252] Wed, 29 December 2010 21:57 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
Mike wrote:

> I can see your frustration... I hadn't realized that this guy hasn't
> taken the time, or perhaps he's using this forum to build in bound
> links to the site he referenced. Still, I'm not sure that flaming
> really helps matters. My $0.02.

Once you get to know richard, you'll probably understand. Case in point,
in his reply to your doing his work by providing a correct answer to the
"and" question, was your effort acknowledged? No.

In one of the other threads ("initial value"), Evan Platt said 'I have
NEVER once seen him say "Thanks for your help."' richard continues in
that mode, as always.

--
-bts
-Four wheels carry the body; two wheels move the soul
Re: AND in the if statement [message #171261 is a reply to message #171242] Wed, 29 December 2010 21:58 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Wed, 29 Dec 2010 12:51:18 -0800 (PST), Mike wrote:

> Dennis,
>
> What was the point of that? When I started with PHP, I was as
> unfamiliar with the jargon and even how to follow the manual pages.
> The guy asked a simple question, so either answer his question or stfu.

He belongs to the "High and mighty holier than thou" group.
If you misspell, fck, he will bash you for it.
He also forgets that he was once in the same boat and now he believes he is
the captain.
Re: AND in the if statement [message #171262 is a reply to message #171248] Wed, 29 December 2010 22:00 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Wed, 29 Dec 2010 13:05:25 -0800 (PST), Captain Paralytic wrote:

> On Dec 29, 8:53 pm, richard <mem...@newsguy.com> wrote:
>> On Wed, 29 Dec 2010 20:37:05 +0000, Denis McMahon wrote:
>>> On 29/12/10 19:37, richard wrote:
>>>> Ok smart people, answer me this as I have not yet found an answer googling.
>>
>>>> if (a=1) echo "hello";
>>
>>> You haven't been listening.
>>
>>> You have been told what is wrong with this at least twice in the last
>>> two days. You are failing to absorb this essential and fundamental piece
>>> of php.
>>
>>>> In BASIC, I can say, if a=1 AND b=2 then do this.
>>>> Meaning, both conditions MUST be true to get to "do this".
>>
>>> php is not basic. You need to use the correct php syntax and constructs
>>> to do things in php. When you learn the basic php syntaxes and
>>> constructs, people may become more helpful.
>>
>>>> Is it possible to include AND in the PHP if and if so, how?
>>
>>>> Maybe like, if (a=1 and b=2) echo "hello";
>>
>>> You say you are familiar with the php.net website, yet you obviously
>>> managed to miss pages referring to control structures, specifically the
>>> use of if, and logical and comparison operators, despite the fact that
>>> they can be found in the clearly labelled control structures and
>>> operators sections of the clearly labelled language reference section of
>>> the clearly labelled manual.
>>
>>> Therefore, for your next lesson, go to the php.net website, find the
>>> manual pages that deal with:
>>
>>> Manual
>>>   Language Reference
>>>       Operators
>>>         Operator Precedence
>>
>>> Manual
>>>   Language Reference
>>>       Operators
>>>         Comparison Operators
>>
>>> Manual
>>>   Language Reference
>>>       Operators
>>>         Logical Operators
>>
>>> Manual
>>>   Language Reference
>>>     Control Structures
>>>       If
>>
>>> Once you have read those pages, you will either know the answer to the
>>> questions that you have asked here, or, if you do not then know the
>>> answers, will instead know that you have no aptitude whatsoever for
>>> programming in php and should find another hobby, probably one that does
>>> not involve computers.
>>
>>> Rgds
>>
>>> Denis McMahon
>>
>> If my syntax is wrong then so is the coding at php.net.
>> From php.net's example:
>> <?php
>> if ($a > $b)
>>   echo "a is bigger than b";
>> ?>
>>
>> Where I may use a single = operator in a post, it is only to show what I'm
>> after in the whole.
>> I understand that it is best to use double == operators in real life.
>
> Not "best" you idiot. In php = is an assignment operator and == is a
> comparison one. They do completely different things.
>
> php.net is not wrong, you are an idiot.

Yet, I haven't seen anything on php.net where this is stated.
Authors often overlook the minor details.
Re: AND in the if statement [message #171264 is a reply to message #171262] Wed, 29 December 2010 22:17 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Dec 29, 10:00 pm, richard <mem...@newsguy.com> wrote:
> On Wed, 29 Dec 2010 13:05:25 -0800 (PST), Captain Paralytic wrote:
>> On Dec 29, 8:53 pm, richard <mem...@newsguy.com> wrote:
>>> On Wed, 29 Dec 2010 20:37:05 +0000, Denis McMahon wrote:
>>>> On 29/12/10 19:37, richard wrote:
>>>> > Ok smart people, answer me this as I have not yet found an answer googling.
>
>>>> > if (a=1) echo "hello";
>
>>>> You haven't been listening.
>
>>>> You have been told what is wrong with this at least twice in the last
>>>> two days. You are failing to absorb this essential and fundamental piece
>>>> of php.
>
>>>> > In BASIC, I can say, if a=1 AND b=2 then do this.
>>>> > Meaning, both conditions MUST be true to get to "do this".
>
>>>> php is not basic. You need to use the correct php syntax and constructs
>>>> to do things in php. When you learn the basic php syntaxes and
>>>> constructs, people may become more helpful.
>
>>>> > Is it possible to include AND in the PHP if and if so, how?
>
>>>> > Maybe like, if (a=1 and b=2) echo "hello";
>
>>>> You say you are familiar with the php.net website, yet you obviously
>>>> managed to miss pages referring to control structures, specifically the
>>>> use of if, and logical and comparison operators, despite the fact that
>>>> they can be found in the clearly labelled control structures and
>>>> operators sections of the clearly labelled language reference section of
>>>> the clearly labelled manual.
>
>>>> Therefore, for your next lesson, go to the php.net website, find the
>>>> manual pages that deal with:
>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Operator Precedence
>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Comparison Operators
>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Logical Operators
>
>>>> Manual
>>>> Language Reference
>>>> Control Structures
>>>> If
>
>>>> Once you have read those pages, you will either know the answer to the
>>>> questions that you have asked here, or, if you do not then know the
>>>> answers, will instead know that you have no aptitude whatsoever for
>>>> programming in php and should find another hobby, probably one that does
>>>> not involve computers.
>
>>>> Rgds
>
>>>> Denis McMahon
>
>>> If my syntax is wrong then so is the coding at php.net.
>>> From php.net's example:
>>> <?php
>>> if ($a > $b)
>>> echo "a is bigger than b";
>>> ?>
>
>>> Where I may use a single = operator in a post, it is only to show what I'm
>>> after in the whole.
>>> I understand that it is best to use double == operators in real life.
>
>> Not "best" you idiot. In php = is an assignment operator and == is a
>> comparison one. They do completely different things.
>
>> php.net is not wrong, you are an idiot.
>
> Yet, I haven't seen anything on php.net where this is stated.
> Authors often overlook the minor details.

They may do, but certainly not in this case. In this case idiots
overlook the value of actually reading!
http://php.net/manual/en/language.operators.php
Re: AND in the if statement [message #171265 is a reply to message #171262] Wed, 29 December 2010 22:25 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Dec 29, 10:00 pm, richard <mem...@newsguy.com> wrote:
> On Wed, 29 Dec 2010 13:05:25 -0800 (PST), Captain Paralytic wrote:
>> On Dec 29, 8:53 pm, richard <mem...@newsguy.com> wrote:
>>> On Wed, 29 Dec 2010 20:37:05 +0000, Denis McMahon wrote:
>>>> On 29/12/10 19:37, richard wrote:
>>>> > Ok smart people, answer me this as I have not yet found an answer googling.
>
>>>> > if (a=1) echo "hello";
>
>>>> You haven't been listening.
>
>>>> You have been told what is wrong with this at least twice in the last
>>>> two days. You are failing to absorb this essential and fundamental piece
>>>> of php.
>
>>>> > In BASIC, I can say, if a=1 AND b=2 then do this.
>>>> > Meaning, both conditions MUST be true to get to "do this".
>
>>>> php is not basic. You need to use the correct php syntax and constructs
>>>> to do things in php. When you learn the basic php syntaxes and
>>>> constructs, people may become more helpful.
>
>>>> > Is it possible to include AND in the PHP if and if so, how?
>
>>>> > Maybe like, if (a=1 and b=2) echo "hello";
>
>>>> You say you are familiar with the php.net website, yet you obviously
>>>> managed to miss pages referring to control structures, specifically the
>>>> use of if, and logical and comparison operators, despite the fact that
>>>> they can be found in the clearly labelled control structures and
>>>> operators sections of the clearly labelled language reference section of
>>>> the clearly labelled manual.
>
>>>> Therefore, for your next lesson, go to the php.net website, find the
>>>> manual pages that deal with:
>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Operator Precedence
>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Comparison Operators
>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Logical Operators
>
>>>> Manual
>>>> Language Reference
>>>> Control Structures
>>>> If
>
>>>> Once you have read those pages, you will either know the answer to the
>>>> questions that you have asked here, or, if you do not then know the
>>>> answers, will instead know that you have no aptitude whatsoever for
>>>> programming in php and should find another hobby, probably one that does
>>>> not involve computers.
>
>>>> Rgds
>
>>>> Denis McMahon
>
>>> If my syntax is wrong then so is the coding at php.net.
>>> From php.net's example:
>>> <?php
>>> if ($a > $b)
>>> echo "a is bigger than b";
>>> ?>
>
>>> Where I may use a single = operator in a post, it is only to show what I'm
>>> after in the whole.
>>> I understand that it is best to use double == operators in real life.
>
>> Not "best" you idiot. In php = is an assignment operator and == is a
>> comparison one. They do completely different things.
>
>> php.net is not wrong, you are an idiot.
>
> Yet, I haven't seen anything on php.net where this is stated.
> Authors often overlook the minor details.

As has been pointed out by others, you are constantly accusing the
authors of web sites and books, of not doing their jobs correctly,
when the problem is that you simply do not possess the intelligence to
understand what they have written.

You have purchased an excellent book on php and yet you say that it if
full of stuff that you have to be a super technician to understand.
BULLSHIT. Lots of people by that book and if they were super
technicians, they would not need to.

Stop wasting your time and money. Take up a hobby that does not
require you to use your brain.
Re: AND in the if statement [message #171269 is a reply to message #171244] Wed, 29 December 2010 23:04 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <1vbfb0a9uj34w$(dot)dlg(at)evanplatt(dot)sux>,
richard <member(at)newsguy(dot)com> wrote:

[unlike too many of you fuckers, I know how to snip]

> If my syntax is wrong then so is the coding at php.net.
> From php.net's example:
> <?php
> if ($a > $b)
> echo "a is bigger than b";
> ?>
>
> Where I may use a single = operator in a post, it is only to show what I'm
> after in the whole.
> I understand that it is best to use double == operators in real life.

It's not a question of it being "best". If you don't, then it doesn't
fucking WORK!

Are you starting to understand now.

By the way, I agree with all comments made so far that imply you may not
have the aptitude for programming.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: AND in the if statement [message #171272 is a reply to message #171238] Wed, 29 December 2010 23:09 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <18a130wqz1i57$(dot)dlg(at)evanplatt(dot)sux>,
richard <member(at)newsguy(dot)com> wrote:

> On Wed, 29 Dec 2010 11:42:41 -0800 (PST), Mike wrote:
>
>> Basic... is there (still) such a thing?
>>
>> if( $a==1 && $b==2) { // do some cool stuff }
>>
>> If you use a single =, you'll actually set the value and it'll always
>> be true. the double == checks equality without changing the value.
>> Use || for OR.

> Finally found a site that describes all the good stuff like that.
> http://www.elated.com/articles/php-operators/

And this differs from:

<http://www.php.net/manual/en/language.operators.php>

precisely how? And don't say it's because you need an extra click to get
to each section either.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: AND in the if statement [message #171273 is a reply to message #171244] Wed, 29 December 2010 23:19 Go to previous messageGo to next message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma: 0
Senior Member
richard wrote:
> On Wed, 29 Dec 2010 20:37:05 +0000, Denis McMahon wrote:
>
>> On 29/12/10 19:37, richard wrote:
>>> Ok smart people, answer me this as I have not yet found an answer googling.
>>>
>>> if (a=1) echo "hello";
>> You haven't been listening.
>>
>> You have been told what is wrong with this at least twice in the last
>> two days. You are failing to absorb this essential and fundamental piece
>> of php.
>>
>>> In BASIC, I can say, if a=1 AND b=2 then do this.
>>> Meaning, both conditions MUST be true to get to "do this".
>> php is not basic. You need to use the correct php syntax and constructs
>> to do things in php. When you learn the basic php syntaxes and
>> constructs, people may become more helpful.
>>
>>> Is it possible to include AND in the PHP if and if so, how?
>>>
>>> Maybe like, if (a=1 and b=2) echo "hello";
>> You say you are familiar with the php.net website, yet you obviously
>> managed to miss pages referring to control structures, specifically the
>> use of if, and logical and comparison operators, despite the fact that
>> they can be found in the clearly labelled control structures and
>> operators sections of the clearly labelled language reference section of
>> the clearly labelled manual.
>>
>> Therefore, for your next lesson, go to the php.net website, find the
>> manual pages that deal with:
>>
>> Manual
>> Language Reference
>> Operators
>> Operator Precedence
>>
>> Manual
>> Language Reference
>> Operators
>> Comparison Operators
>>
>> Manual
>> Language Reference
>> Operators
>> Logical Operators
>>
>> Manual
>> Language Reference
>> Control Structures
>> If
>>
>> Once you have read those pages, you will either know the answer to the
>> questions that you have asked here, or, if you do not then know the
>> answers, will instead know that you have no aptitude whatsoever for
>> programming in php and should find another hobby, probably one that does
>> not involve computers.
>>
>> Rgds
>>
>> Denis McMahon
>
> If my syntax is wrong then so is the coding at php.net.
> From php.net's example:
> <?php
> if ($a > $b)
> echo "a is bigger than b";
> ?>
>
> Where I may use a single = operator in a post, it is only to show what I'm
> after in the whole.
> I understand that it is best to use double == operators in real life.

Another concept you need to learn is not presenting one problem while
your after something else. You'll get called on it every time. These
folks are trying to help, really they are. But you have to meet them
halfway.

= assignment
== test value
=== test type and value


--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Re: AND in the if statement [message #171274 is a reply to message #171262] Wed, 29 December 2010 23:29 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 29/12/10 22:00, richard wrote:
> On Wed, 29 Dec 2010 13:05:25 -0800 (PST), Captain Paralytic wrote:
>
>> On Dec 29, 8:53 pm, richard <mem...@newsguy.com> wrote:
>>> On Wed, 29 Dec 2010 20:37:05 +0000, Denis McMahon wrote:
>>>> On 29/12/10 19:37, richard wrote:
>>>> > Ok smart people, answer me this as I have not yet found an answer googling.
>>>
>>>> > if (a=1) echo "hello";
>>>
>>>> You haven't been listening.
>>>
>>>> You have been told what is wrong with this at least twice in the last
>>>> two days. You are failing to absorb this essential and fundamental piece
>>>> of php.
>>>
>>>> > In BASIC, I can say, if a=1 AND b=2 then do this.
>>>> > Meaning, both conditions MUST be true to get to "do this".
>>>
>>>> php is not basic. You need to use the correct php syntax and constructs
>>>> to do things in php. When you learn the basic php syntaxes and
>>>> constructs, people may become more helpful.
>>>
>>>> > Is it possible to include AND in the PHP if and if so, how?
>>>
>>>> > Maybe like, if (a=1 and b=2) echo "hello";
>>>
>>>> You say you are familiar with the php.net website, yet you obviously
>>>> managed to miss pages referring to control structures, specifically the
>>>> use of if, and logical and comparison operators, despite the fact that
>>>> they can be found in the clearly labelled control structures and
>>>> operators sections of the clearly labelled language reference section of
>>>> the clearly labelled manual.
>>>
>>>> Therefore, for your next lesson, go to the php.net website, find the
>>>> manual pages that deal with:
>>>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Operator Precedence
>>>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Comparison Operators
>>>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Logical Operators
>>>
>>>> Manual
>>>> Language Reference
>>>> Control Structures
>>>> If
>>>
>>>> Once you have read those pages, you will either know the answer to the
>>>> questions that you have asked here, or, if you do not then know the
>>>> answers, will instead know that you have no aptitude whatsoever for
>>>> programming in php and should find another hobby, probably one that does
>>>> not involve computers.
>>>
>>>> Rgds
>>>
>>>> Denis McMahon
>>>
>>> If my syntax is wrong then so is the coding at php.net.
>>> From php.net's example:
>>> <?php
>>> if ($a > $b)
>>> echo "a is bigger than b";
>>> ?>
>>>
>>> Where I may use a single = operator in a post, it is only to show what I'm
>>> after in the whole.
>>> I understand that it is best to use double == operators in real life.
>>
>> Not "best" you idiot. In php = is an assignment operator and == is a
>> comparison one. They do completely different things.
>>
>> php.net is not wrong, you are an idiot.
>
> Yet, I haven't seen anything on php.net where this is stated.
> Authors often overlook the minor details.

And yet you would have us believe that you have looked at:

Manual
Language Reference
Operators
Comparison Operators

which lists all the valid comparison operators for php. Meanwhile, over on:

Manual
Language Reference
Operators
Assignment Operators

it clearly defines what is a valid php assignment operator.

And yet you can not find this information? The only possible reasons are:

a) that you're not looking for it;
b) that you're incapable of absorbing it when you read it;
c) that you're so lacking in comprehension of basic programming concepts
such as "operators", "control structures", "data types", "assignment"
and "comparison" that you lack the fundamental knowledge needed to
navigate any programming language reference in a meaningful fashion.

The information that you are seeking is present in a clearly identified
form on the website that you claim to be unable to be able to find it
on. Almost (I can think of one other exception) everyone else in this
newsgroup is capable of locating and correctly interpreting that
information without any help whatsoever, yet you insist that it can not
be found even after receiving clear and unambiguous pointers to specific
parts of the on line documentation.

This tells me a great deal about your abilities and mindset.
Specifically that I'd be wasting my time in trying to give you any
further assistance whatsoever.

Rgds

Denis McMahon
Re: AND in the if statement [message #171290 is a reply to message #171262] Thu, 30 December 2010 01:43 Go to previous messageGo to next message
Kim Andr Aker is currently offline  Kim Andr Aker
Messages: 17
Registered: September 2010
Karma: 0
Junior Member
PÃ¥ Wed, 29 Dec 2010 23:00:57 +0100, skrev richard <member(at)newsguy(dot)com>:

> On Wed, 29 Dec 2010 13:05:25 -0800 (PST), Captain Paralytic wrote:
>
>> On Dec 29, 8:53 pm, richard <mem...@newsguy.com> wrote:
>>> On Wed, 29 Dec 2010 20:37:05 +0000, Denis McMahon wrote:
>>>> On 29/12/10 19:37, richard wrote:
>>>> > Ok smart people, answer me this as I have not yet found an answer
>>>> > googling.
>>>
>>>> > if (a=1) echo "hello";
>>>
>>>> You haven't been listening.
>>>
>>>> You have been told what is wrong with this at least twice in the last
>>>> two days. You are failing to absorb this essential and fundamental
>>>> piece
>>>> of php.
>>>
>>>> > In BASIC, I can say, if a=1 AND b=2 then do this.
>>>> > Meaning, both conditions MUST be true to get to "do this".
>>>
>>>> php is not basic. You need to use the correct php syntax and
>>>> constructs
>>>> to do things in php. When you learn the basic php syntaxes and
>>>> constructs, people may become more helpful.
>>>
>>>> > Is it possible to include AND in the PHP if and if so, how?
>>>
>>>> > Maybe like, if (a=1 and b=2) echo "hello";
>>>
>>>> You say you are familiar with the php.net website, yet you obviously
>>>> managed to miss pages referring to control structures, specifically
>>>> the
>>>> use of if, and logical and comparison operators, despite the fact that
>>>> they can be found in the clearly labelled control structures and
>>>> operators sections of the clearly labelled language reference section
>>>> of
>>>> the clearly labelled manual.
>>>
>>>> Therefore, for your next lesson, go to the php.net website, find the
>>>> manual pages that deal with:
>>>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Operator Precedence
>>>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Comparison Operators
>>>
>>>> Manual
>>>> Language Reference
>>>> Operators
>>>> Logical Operators
>>>
>>>> Manual
>>>> Language Reference
>>>> Control Structures
>>>> If
>>>
>>>> Once you have read those pages, you will either know the answer to the
>>>> questions that you have asked here, or, if you do not then know the
>>>> answers, will instead know that you have no aptitude whatsoever for
>>>> programming in php and should find another hobby, probably one that
>>>> does
>>>> not involve computers.
>>>
>>>> Rgds
>>>
>>>> Denis McMahon
>>>
>>> If my syntax is wrong then so is the coding at php.net.
>>> From php.net's example:
>>> <?php
>>> if ($a > $b)
>>> echo "a is bigger than b";
>>> ?>
>>>
>>> Where I may use a single = operator in a post, it is only to show what
>>> I'm
>>> after in the whole.
>>> I understand that it is best to use double == operators in real life.
>>
>> Not "best" you idiot. In php = is an assignment operator and == is a
>> comparison one. They do completely different things.
>>
>> php.net is not wrong, you are an idiot.
>
> Yet, I haven't seen anything on php.net where this is stated.
> Authors often overlook the minor details.

Not quite. Quoted from http://php.net/language.operators.assignment (first
lines):
The basic assignment operator is "=". Your first inclination might be to
think of this as "equal to". Don't. It really means that the left operand
gets set to the value of the expression on the rights (that is, "gets set
to").

Feel free to read up on comparison operators as well:
http://php.net/language.operators.comparison

--
Kim André Akerø
- kimandre(at)NOSPAMbetadome(dot)com
(remove NOSPAM to contact me directly)
Re: AND in the if statement [message #171294 is a reply to message #171262] Thu, 30 December 2010 02:48 Go to previous messageGo to next message
Leonardo Azpurua is currently offline  Leonardo Azpurua
Messages: 46
Registered: December 2010
Karma: 0
Member
"richard" <member(at)newsguy(dot)com> escribió en el mensaje

> Yet, I haven't seen anything on php.net where this is stated.
> Authors often overlook the minor details.

http://www.php.net/manual/en/language.operators.comparison.php

You can't blame php.net if you are an idiot.

There are assignment operators, including "=", and comparison operators,
which include == and ===.

Assignment != comparison.

It is nobody's fault if you can't understand such a simple thing.

--
Re: AND in the if statement [message #171464 is a reply to message #171234] Wed, 05 January 2011 01:18 Go to previous messageGo to next message
spambait is currently offline  spambait
Messages: 35
Registered: September 2010
Karma: 0
Member
In article <1cqz2sz54ke4v$(dot)dlg(at)evanplatt(dot)sux>, richard <member(at)newsguy(dot)com> wrote:
> Ok smart people, answer me this as I have not yet found an answer googling.

"Give me a fish!"

No. I'm not going to give you a fish. Below are some links that might help you
learn to fish.
>
> if (a=1) echo "hello";
>
> In BASIC, I can say, if a=1 AND b=2 then do this.
> Meaning, both conditions MUST be true to get to "do this".

http://www.php.net/manual/en/language.operators.assignment.php
http://www.php.net/manual/en/language.operators.comparison.php
>
> Is it possible to include AND in the PHP if and if so, how?

Yes.
http://www.php.net/manual/en/language.operators.logical.php
>
> Maybe like, if (a=1 and b=2) echo "hello";

Maybe something similar to that. RTFM [*] and learn something.

[* RTFM = Read The Fishing Manual, of course.]
Re: AND in the if statement [message #171465 is a reply to message #171238] Wed, 05 January 2011 01:33 Go to previous messageGo to next message
spambait is currently offline  spambait
Messages: 35
Registered: September 2010
Karma: 0
Member
In article <18a130wqz1i57$(dot)dlg(at)evanplatt(dot)sux>, richard <member(at)newsguy(dot)com> wrote:
> On Wed, 29 Dec 2010 11:42:41 -0800 (PST), Mike wrote:
>
>> Basic... is there (still) such a thing?
>>
>> if( $a==1 && $b==2) { // do some cool stuff }
>>
>> If you use a single =, you'll actually set the value and it'll always
>> be true. the double == checks equality without changing the value.
>> Use || for OR.
>>
>> Mike
>
> Finally found a site that describes all the good stuff like that.

???

It's ALL described at www.php.net.

> http://www.elated.com/articles/php-operators/
>
> I saw one bit of code that showed === and I'm reacting like wtf?
> Had not seen that one before. Now I have a resource for that stuff.

You've had one all along: www.php.net, as people have been telling you for
more than a year.
Re: AND in the if statement [message #171466 is a reply to message #171244] Wed, 05 January 2011 01:35 Go to previous messageGo to next message
spambait is currently offline  spambait
Messages: 35
Registered: September 2010
Karma: 0
Member
In article <1vbfb0a9uj34w$(dot)dlg(at)evanplatt(dot)sux>, richard <member(at)newsguy(dot)com> wrote:

> Where I may use a single = operator in a post, it is only to show what I'm
> after in the whole.
> I understand that it is best to use double == operators in real life.

You *still* don't understand the difference, do you?
Re: AND in the if statement [message #171467 is a reply to message #171262] Wed, 05 January 2011 01:36 Go to previous messageGo to next message
spambait is currently offline  spambait
Messages: 35
Registered: September 2010
Karma: 0
Member
In article <1h7q9ffww53nc(dot)dlg(at)evanplatt(dot)sux>, richard <member(at)newsguy(dot)com> wrote:
> On Wed, 29 Dec 2010 13:05:25 -0800 (PST), Captain Paralytic wrote:

>> Not "best" you idiot. In php = is an assignment operator and == is a
>> comparison one. They do completely different things.
>>
>> php.net is not wrong, you are an idiot.
>
> Yet, I haven't seen anything on php.net where this is stated.

Then you haven't been looking very hard.
Re: AND in the if statement [message #171625 is a reply to message #171467] Wed, 12 January 2011 16:01 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 1/4/2011 8:36 PM, Doug Miller wrote:
> In article<1h7q9ffww53nc(dot)dlg(at)evanplatt(dot)sux>, richard<member(at)newsguy(dot)com> wrote:
>> On Wed, 29 Dec 2010 13:05:25 -0800 (PST), Captain Paralytic wrote:
>
>>> Not "best" you idiot. In php = is an assignment operator and == is a
>>> comparison one. They do completely different things.
>>>
>>> php.net is not wrong, you are an idiot.
>>
>> Yet, I haven't seen anything on php.net where this is stated.

www.php.net
www.w3schools.com
Barnes and Noble -- PHP for Dummies.

--
Shelly
Re: AND in the if statement [message #171632 is a reply to message #171625] Wed, 12 January 2011 21:01 Go to previous message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Jan 12, 4:01 pm, sheldonlg <sheldo...@thevillages.net> wrote:
> On 1/4/2011 8:36 PM, Doug Miller wrote:
>
>> In article<1h7q9ffww53nc....@evanplatt.sux>, richard<mem...@newsguy.com>  wrote:
>>> On Wed, 29 Dec 2010 13:05:25 -0800 (PST), Captain Paralytic wrote:
>
>>>> Not "best" you idiot. In php = is an assignment operator and == is a
>>>> comparison one. They do completely different things.
>
>>>> php.net is not wrong, you are an idiot.
>
>>> Yet, I haven't seen anything on php.net where this is stated.
>
> www.php.netwww.w3schools.com
> Barnes and Noble -- PHP for Dummies.
>
> --
> Shelly

PHP for Dummies is too advanced for Richard
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: php-debug-faq-post in progress
Next Topic: using same variable twice on same page
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 23:50:59 GMT 2024

Total time taken to generate the page: 0.07965 seconds