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

Home » Imported messages » comp.lang.php » using same variable twice on same page
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
using same variable twice on same page [message #171191] Wed, 29 December 2010 05:07 Go to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
Everything I have looked at so far talks of how to use one variable ONCE!
Nothing I've seen even comes to close as to how to utilize the same
variable in a different location on the same page.

for instance:
initial value of $year="1960"
<div> <?php echo $year;?></div>
<div> blah blah blah </div>
<div> yada yada yada </div>
Assume here we change $year to be "1961"
<div> <?php if ($year="1961") echo $year; ?></div>

From what I've tried, no change is made.
Even if I use a second instance of $_GET().

What is the best way of doing what I want to happen?

As you know, google is a hodge podge for looking up something with more
than one word in the search bar.
Re: using same variable twice on same page [message #171194 is a reply to message #171191] Wed, 29 December 2010 06:56 Go to previous messageGo to next message
Adrienne Boswell is currently offline  Adrienne Boswell
Messages: 25
Registered: October 2010
Karma: 0
Junior Member
Gazing into my crystal ball I observed richard <member(at)newsguy(dot)com>
writing in news:yzhlacpa809x(dot)dlg(at)evanplatt(dot)sux:

> Everything I have looked at so far talks of how to use one variable
ONCE!
> Nothing I've seen even comes to close as to how to utilize the same
> variable in a different location on the same page.

I think you have HTML and PHP mixed up. You cannot use the an ID more
than once in an HTML page, class yes. For variables, you do say:

<?php

if(isset($_GET['year']))
{$year = $_GET['year'];
//do some testing to make sure the value is what you want}
else
{$year = 1960;}

echo "<p>The initial year is ".$year.".</p>";

echo "<p>Loop 10 years:</p>";

for($i=0;$i<10;++$i)
{
echo "<p>The year is now ".$year+$i.".</p>";
}
?>

>
> for instance:
> initial value of $year="1960"
> <div> <?php echo $year;?></div>
> <div> blah blah blah </div>
> <div> yada yada yada </div>
> Assume here we change $year to be "1961"
> <div> <?php if ($year="1961") echo $year; ?></div>
>
> From what I've tried, no change is made.
> Even if I use a second instance of $_GET().

$_GET(variable) does not work. You need $_GET[variable].

>
> What is the best way of doing what I want to happen?
>
> As you know, google is a hodge podge for looking up something with more
> than one word in the search bar.
>

Did you ever think about using the source, PHP.net?

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Re: using same variable twice on same page [message #171196 is a reply to message #171191] Wed, 29 December 2010 10:42 Go to previous messageGo to next message
Derek Turner is currently offline  Derek Turner
Messages: 48
Registered: October 2010
Karma: 0
Member
On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:

> <?php if ($year="1961")


This simply sets $year to "1961" and will always return 'true'

I leave it to you RTFM and find out why.
Re: using same variable twice on same page [message #171197 is a reply to message #171194] Wed, 29 December 2010 11:25 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Adrienne Boswell wrote:

> richard [wrote]:
>> Everything I have looked at so far talks of how to use one variable
> ONCE!
^^
Please get a decent newsreader that does not produce broken quotes.

> […]
> <?php
>
> if(isset($_GET['year']))
> {$year = $_GET['year'];
> //do some testing to make sure the value is what you want}
> else
> {$year = 1960;}
>
> echo "<p>The initial year is ".$year.".</p>";
>
> echo "<p>Loop 10 years:</p>";
>
> for($i=0;$i<10;++$i)
> {
> echo "<p>The year is now ".$year+$i.".</p>";
> }
> ?>

The following might be slightly less confusing, and slightly more efficient:

<?php
$year = (isset($_GET['year'])) ? $_GET['year'] : 1960;

/* do some testing to make sure the value is what you want */
?>

<p>The initial year is <?php echo $year; ?>.</p>

<p>Loop 10 years:</p>

<?php
for ($i = $year, $maxYear = $year + 10;
$i < $maxYear;
++$i)
{
?><p>The year is now <?php echo $i; ?>.</p><?php
}
?>


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Re: using same variable twice on same page [message #171201 is a reply to message #171197] Wed, 29 December 2010 13:19 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/29/2010 6:25 AM, Thomas 'PointedEars' Lahn wrote:
> Adrienne Boswell wrote:
>
>> richard [wrote]:
>>> Everything I have looked at so far talks of how to use one variable
>> ONCE!
> ^^
> Please get a decent newsreader that does not produce broken quotes.
>

There is nothing wrong with his newsreader. If you see broken quotes,
you need to check YOUR newsreader.

>> […]
>> <?php
>>
>> if(isset($_GET['year']))
>> {$year = $_GET['year'];
>> //do some testing to make sure the value is what you want}
>> else
>> {$year = 1960;}
>>
>> echo "<p>The initial year is ".$year.".</p>";
>>
>> echo "<p>Loop 10 years:</p>";
>>
>> for($i=0;$i<10;++$i)
>> {
>> echo "<p>The year is now ".$year+$i.".</p>";
>> }
>> ?>
>
> The following might be slightly less confusing, and slightly more efficient:
>
> <?php
> $year = (isset($_GET['year'])) ? $_GET['year'] : 1960;
>
> /* do some testing to make sure the value is what you want */
> ?>
>
> <p>The initial year is<?php echo $year; ?>.</p>
>
> <p>Loop 10 years:</p>
>
> <?php
> for ($i = $year, $maxYear = $year + 10;
> $i< $maxYear;
> ++$i)
> {
> ?><p>The year is now<?php echo $i; ?>.</p><?php
> }
> ?>
>
>
> PointedEars

Which does not answer richard's question. But that's pretty normal for you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: using same variable twice on same page [message #171202 is a reply to message #171191] Wed, 29 December 2010 13:21 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/29/2010 12:07 AM, richard wrote:
> Everything I have looked at so far talks of how to use one variable ONCE!
> Nothing I've seen even comes to close as to how to utilize the same
> variable in a different location on the same page.
>
> for instance:
> initial value of $year="1960"
> <div> <?php echo $year;?></div>
> <div> blah blah blah</div>
> <div> yada yada yada</div>
> Assume here we change $year to be "1961"
> <div> <?php if ($year="1961") echo $year; ?></div>
>
> From what I've tried, no change is made.
> Even if I use a second instance of $_GET().
>
> What is the best way of doing what I want to happen?
>
> As you know, google is a hodge podge for looking up something with more
> than one word in the search bar.

Richard, you really need to get a good book on php. Trying to
haphazardly search the internet doesn't work well. And while php.net is
a good reference, I don't find it to be a good learning tool. Please
save yourself a lot of heartache and spend a few dollars for a good book
to help you learn.

As for your question - you're confusing '=' and '=='. There is a
difference.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: using same variable twice on same page [message #171205 is a reply to message #171202] Wed, 29 December 2010 14:15 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, 1:21 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 12/29/2010 12:07 AM, richard wrote:
>
>
>
>
>
>> Everything I have looked at so far talks of how to use one variable ONCE!
>> Nothing I've seen even comes to close as to how to utilize the same
>> variable in a different location on the same page.
>
>> for instance:
>> initial value of $year="1960"
>> <div>  <?php echo $year;?></div>
>> <div>  blah blah blah</div>
>> <div>  yada yada yada</div>
>> Assume here we change $year to be "1961"
>> <div>  <?php if ($year="1961") echo $year; ?></div>
>
>>  From what I've tried, no change is made.
>> Even if I use a second instance of $_GET().
>
>> What is the best way of doing what I want to happen?
>
>> As you know, google is a hodge podge for looking up something with more
>> than one word in the search bar.
>
> Richard, you really need to get a good book on php.  Trying to
> haphazardly search the internet doesn't work well.  And while php.net is
> a good reference, I don't find it to be a good learning tool.  Please
> save yourself a lot of heartache and spend a few dollars for a good book
> to help you learn.
>
> As for your question - you're confusing '=' and '=='.  There is a
> difference.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

In the year since Richard has been regularly posting, I would have
expected him to have at least run through http://www.w3schools.com/php/default.asp
and/or http://www.tizag.com/phpT/
and to have obtained a basic knowledge of the syntax of php.

Now either he has not had the intelligence to have searched for php
tutorials, or he has done them but has not had the intelligence to
understand anything he has done.

Either way, telling him to buy a book on php is a rather cruel way of
wasting his money.

I've suggested before that he and JRough should go into partnership.
They could have endless fun together hitting random keys and
pretending that they are programming.

I'm sorry if this seems rude, but it is fairly obvious that some
people simply do not have the aptitude for programming and I think it
far better to let them know this so that they can go off and try
something else.
Re: using same variable twice on same page [message #171209 is a reply to message #171205] Wed, 29 December 2010 15:00 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/29/2010 9:15 AM, Captain Paralytic wrote:
> On Dec 29, 1:21 pm, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 12/29/2010 12:07 AM, richard wrote:
>>
>>
>>
>>
>>
>>> Everything I have looked at so far talks of how to use one variable ONCE!
>>> Nothing I've seen even comes to close as to how to utilize the same
>>> variable in a different location on the same page.
>>
>>> for instance:
>>> initial value of $year="1960"
>>> <div> <?php echo $year;?></div>
>>> <div> blah blah blah</div>
>>> <div> yada yada yada</div>
>>> Assume here we change $year to be "1961"
>>> <div> <?php if ($year="1961") echo $year; ?></div>
>>
>>> From what I've tried, no change is made.
>>> Even if I use a second instance of $_GET().
>>
>>> What is the best way of doing what I want to happen?
>>
>>> As you know, google is a hodge podge for looking up something with more
>>> than one word in the search bar.
>>
>> Richard, you really need to get a good book on php. Trying to
>> haphazardly search the internet doesn't work well. And while php.net is
>> a good reference, I don't find it to be a good learning tool. Please
>> save yourself a lot of heartache and spend a few dollars for a good book
>> to help you learn.
>>
>> As for your question - you're confusing '=' and '=='. There is a
>> difference.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> In the year since Richard has been regularly posting, I would have
> expected him to have at least run through http://www.w3schools.com/php/default.asp
> and/or http://www.tizag.com/phpT/
> and to have obtained a basic knowledge of the syntax of php.
>
> Now either he has not had the intelligence to have searched for php
> tutorials, or he has done them but has not had the intelligence to
> understand anything he has done.
>
> Either way, telling him to buy a book on php is a rather cruel way of
> wasting his money.
>
> I've suggested before that he and JRough should go into partnership.
> They could have endless fun together hitting random keys and
> pretending that they are programming.
>
> I'm sorry if this seems rude, but it is fairly obvious that some
> people simply do not have the aptitude for programming and I think it
> far better to let them know this so that they can go off and try
> something else.

I don't know, Paul. You may be right. I've had students in my classes
before who are completely lost even on simple non-language specific
pseudo-code examples. However, others have started out badly, and with
the right tools, have succeeded.

Personally, I don't think w3schools is all that great a learning tool.
It's ok for some stuff, but pretty shallow in their coverage of most
stuff. As for tizag.com - heck, I've never run into that one, either.
I'll have to take a look at it.

But it's obvious Richard is trying, and isn't going to give up. So if I
can point him in a direction which will help him better than newsgroups
do (usenet isn't good for everything!), I will.

And as for his problem - it's a common one I see all the time in my
classes, even from more experienced programmers, and one I make with
embarrassing regularity myself :)


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: using same variable twice on same page [message #171210 is a reply to message #171191] Wed, 29 December 2010 15:02 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 05:07, richard wrote:
> Everything I have looked at so far talks of how to use one variable ONCE!
> Nothing I've seen even comes to close as to how to utilize the same
> variable in a different location on the same page.
>
> for instance:
> initial value of $year="1960"
> <div> <?php echo $year;?></div>
> <div> blah blah blah </div>
> <div> yada yada yada </div>
> Assume here we change $year to be "1961"
> <div> <?php if ($year="1961") echo $year; ?></div>
>
> From what I've tried, no change is made.

Then whatever code you have at 'Assume here we change $year to be
"1961"' is, to use the appropriate technical term, fucked code, and you
need to fix it.

> Even if I use a second instance of $_GET().

1) You've already been told that $_GET is an array, not a function call,
and that you must use $_GET[some_fieldname_in_quotes] rather than
$_GET(some_random_text). If you can not absorb this simple bit of
information, you will never learn to code in php, so you should stop
trying now.

2) I don't see a first instance of a "$_GET['some_field_name']" or even
a richard_fucked "$_GET(something)" in the example code you offered, so
I have no idea what you mean when you say the problem occurs even if you
use a second instance of $_GET().

Rgds

Denis McMahon
Re: using same variable twice on same page [message #171211 is a reply to message #171205] Wed, 29 December 2010 15:05 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 29-12-10 15:15, Captain Paralytic wrote:
> On Dec 29, 1:21 pm, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 12/29/2010 12:07 AM, richard wrote:
>>
>>
>>
>>
>>
>>> Everything I have looked at so far talks of how to use one variable ONCE!
>>> Nothing I've seen even comes to close as to how to utilize the same
>>> variable in a different location on the same page.
>>
>>> for instance:
>>> initial value of $year="1960"
>>> <div> <?php echo $year;?></div>
>>> <div> blah blah blah</div>
>>> <div> yada yada yada</div>
>>> Assume here we change $year to be "1961"
>>> <div> <?php if ($year="1961") echo $year; ?></div>
>>
>>> From what I've tried, no change is made.
>>> Even if I use a second instance of $_GET().
>>
>>> What is the best way of doing what I want to happen?
>>
>>> As you know, google is a hodge podge for looking up something with more
>>> than one word in the search bar.
>>
>> Richard, you really need to get a good book on php. Trying to
>> haphazardly search the internet doesn't work well. And while php.net is
>> a good reference, I don't find it to be a good learning tool. Please
>> save yourself a lot of heartache and spend a few dollars for a good book
>> to help you learn.
>>
>> As for your question - you're confusing '=' and '=='. There is a
>> difference.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> In the year since Richard has been regularly posting, I would have
> expected him to have at least run through http://www.w3schools.com/php/default.asp
> and/or http://www.tizag.com/phpT/
> and to have obtained a basic knowledge of the syntax of php.
>
> Now either he has not had the intelligence to have searched for php
> tutorials, or he has done them but has not had the intelligence to
> understand anything he has done.

Since when do you care about the intelligence of anyone else?
He definitely wants to learn, otherwise he would not post a question here.

>
> Either way, telling him to buy a book on php is a rather cruel way of
> wasting his money.

Its HIS money, not yours

>
> I've suggested before that he and JRough should go into partnership.
> They could have endless fun together hitting random keys and
> pretending that they are programming.

Spamming someone else's name is not very polite. Especially because this
person has no (direct) reference to this thread.

>
> I'm sorry if this seems rude, but it is fairly obvious that some
> people simply do not have the aptitude for programming and I think it
> far better to let them know this so that they can go off and try
> something else.

I dont think you ARE sorry.

If you really think he's not able to learn some programming, than you
could also simply ignore his messages, which saves you your 'valuable'
time, and saves some other people a lot of frustration.

--
Luuk
Re: using same variable twice on same page [message #171212 is a reply to message #171201] Wed, 29 December 2010 15:10 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Wed, 29 Dec 2010 08:19:57 -0500, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

> On 12/29/2010 6:25 AM, Thomas 'PointedEars' Lahn wrote:
>> Adrienne Boswell wrote:
>>
>>> richard [wrote]:
>>>> Everything I have looked at so far talks of how to use one variable
>>> ONCE!
>> ^^
>> Please get a decent newsreader that does not produce broken quotes.
>>
>
> There is nothing wrong with his newsreader. If you see broken quotes,
> you need to check YOUR newsreader.

I see broken quotes too, and I've disabled all forms of word wrap.

Do you not see

> Everything I have looked at so far talks of how to use one variable
ONCE!

?
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: using same variable twice on same page [message #171213 is a reply to message #171210] Wed, 29 December 2010 15:15 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 15:02, Denis McMahon wrote:
> On 29/12/10 05:07, richard wrote:
>> Everything I have looked at so far talks of how to use one variable ONCE!
>> Nothing I've seen even comes to close as to how to utilize the same
>> variable in a different location on the same page.
>>
>> for instance:
>> initial value of $year="1960"
>> <div> <?php echo $year;?></div>
>> <div> blah blah blah </div>
>> <div> yada yada yada </div>
>> Assume here we change $year to be "1961"
>> <div> <?php if ($year="1961") echo $year; ?></div>
>>
>> From what I've tried, no change is made.
>
> Then whatever code you have at 'Assume here we change $year to be
> "1961"' is, to use the appropriate technical term, fucked code, and you
> need to fix it.

Actually I missed something here that's been picked up by Jerry.

$ cat testdick.php
<?php
if ($year="1961") echo $year . "\n";
?>
$ php5 testdick.php
1961
$

and

$ cat testdick2.php
<?php
$year = "1960";
echo $year . "\n";
$year = $year + 1;
echo $year . "\n";
if ($year=="1961") echo $year . "\n";
$year = "1961";
echo $year . "\n";
if ($year=="1961") echo $year . "\n";
?>
$ php5 testdick2.php
1960
1961
1961
1961
1961
$

So if you're not getting an output of 1961 where you expect it,
something else is fundamentally fucked.

Rgds

Denis McMahon
Re: using same variable twice on same page [message #171214 is a reply to message #171212] Wed, 29 December 2010 15:21 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 15:10, Evan Platt wrote:
> On Wed, 29 Dec 2010 08:19:57 -0500, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 12/29/2010 6:25 AM, Thomas 'PointedEars' Lahn wrote:
>>> Adrienne Boswell wrote:
>>>
>>>> richard [wrote]:
>>>> > Everything I have looked at so far talks of how to use one variable
>>>> ONCE!
>>> ^^
>>> Please get a decent newsreader that does not produce broken quotes.
>>>
>>
>> There is nothing wrong with his newsreader. If you see broken quotes,
>> you need to check YOUR newsreader.
>
> I see broken quotes too, and I've disabled all forms of word wrap.
>
> Do you not see
>
>> Everything I have looked at so far talks of how to use one variable
> ONCE!

I looked at the message source, and there's a newline before "ONCE!",
but no quote character after the newline. I'd call that broken quoting
myself.

Whether it was broken by the newsreader or some action of the poster is
moot - if the poster manually inserted the newline and didn't add a
quote character it was user action, not a broken newsreader, that led to
the broken quoting.

Rgds

Denis McMahon
Re: using same variable twice on same page [message #171215 is a reply to message #171202] Wed, 29 December 2010 15:57 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 08:21:45 -0500, Jerry Stuckle wrote:

> On 12/29/2010 12:07 AM, richard wrote:
>> Everything I have looked at so far talks of how to use one variable ONCE!
>> Nothing I've seen even comes to close as to how to utilize the same
>> variable in a different location on the same page.
>>
>> for instance:
>> initial value of $year="1960"
>> <div> <?php echo $year;?></div>
>> <div> blah blah blah</div>
>> <div> yada yada yada</div>
>> Assume here we change $year to be "1961"
>> <div> <?php if ($year="1961") echo $year; ?></div>
>>
>> From what I've tried, no change is made.
>> Even if I use a second instance of $_GET().
>>
>> What is the best way of doing what I want to happen?
>>
>> As you know, google is a hodge podge for looking up something with more
>> than one word in the search bar.
>
> Richard, you really need to get a good book on php. Trying to
> haphazardly search the internet doesn't work well. And while php.net is
> a good reference, I don't find it to be a good learning tool. Please
> save yourself a lot of heartache and spend a few dollars for a good book
> to help you learn.
>
> As for your question - you're confusing '=' and '=='. There is a
> difference.

Jerry, I bought the PHP 5 bible ok? Like most of these damn things, it is
so filled with gobly gook only a trained technician could understand.
Several times he spends 10 pages on crap that has no relation to anything
any person programming needs to know.

And for you captain pukehead, I constantly read through php.net, tizag, and
a host of others.
Re: using same variable twice on same page [message #171216 is a reply to message #171197] Wed, 29 December 2010 16:02 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:25:09 +0100, Thomas 'PointedEars' Lahn wrote:

> Adrienne Boswell wrote:
>
>> richard [wrote]:
>>> Everything I have looked at so far talks of how to use one variable
>> ONCE!
> ^^
> Please get a decent newsreader that does not produce broken quotes.

This is totally hillarious. Such great minds arguing like little school
boys over a minor typo which was NOT caused by MY news client.
Re: using same variable twice on same page [message #171217 is a reply to message #171216] Wed, 29 December 2010 16:44 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
richard wrote:

> On Wed, 29 Dec 2010 12:25:09 +0100, Thomas 'PointedEars' Lahn wrote:
>> Adrienne Boswell wrote:
>>> richard [wrote]:
>>>> Everything I have looked at so far talks of how to use one variable
>>> ONCE!
>> ^^
>> Please get a decent newsreader that does not produce broken quotes.
>
> This is totally hillarious.

Simple minds are easily amused.

> Such great minds arguing like- little school boys over a minor typo

(You are arguing about it yourself now.)

Chances are that it was the Adrienne's newsreader which missed completing
the quote character when line-breaking the quotation. Hence my (implicit)
advice that they check its settings or get a better one.

> which was NOT caused by MY news client.

Nobody said it was. However, your posting slightly too long a line (73
characters) for Adrienne's settings (perhaps 72 characters max.) might have
contributed to this problem.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Re: using same variable twice on same page [message #171218 is a reply to message #171215] Wed, 29 December 2010 16:53 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, 3:57 pm, richard <mem...@newsguy.com> wrote:
> On Wed, 29 Dec 2010 08:21:45 -0500, Jerry Stuckle wrote:
>> On 12/29/2010 12:07 AM, richard wrote:
>>> Everything I have looked at so far talks of how to use one variable ONCE!
>>> Nothing I've seen even comes to close as to how to utilize the same
>>> variable in a different location on the same page.
>
>>> for instance:
>>> initial value of $year="1960"
>>> <div>  <?php echo $year;?></div>
>>> <div>  blah blah blah</div>
>>> <div>  yada yada yada</div>
>>> Assume here we change $year to be "1961"
>>> <div>  <?php if ($year="1961") echo $year; ?></div>
>
>>>  From what I've tried, no change is made.
>>> Even if I use a second instance of $_GET().
>
>>> What is the best way of doing what I want to happen?
>
>>> As you know, google is a hodge podge for looking up something with more
>>> than one word in the search bar.
>
>> Richard, you really need to get a good book on php.  Trying to
>> haphazardly search the internet doesn't work well.  And while php.net is
>> a good reference, I don't find it to be a good learning tool.  Please
>> save yourself a lot of heartache and spend a few dollars for a good book
>> to help you learn.
>
>> As for your question - you're confusing '=' and '=='.  There is a
>> difference.
>
> Jerry, I bought the PHP 5 bible ok? Like most of these damn things, it is
> so filled with gobly gook only a trained technician could understand.
> Several times he spends 10 pages on crap that has no relation to anything
> any person programming needs to know.
>
> And for you captain pukehead, I constantly read through php.net, tizag, and
> a host of others.

And there is my point. If you have constantly read this stuff and you
still do not understand the basic syntax of php, then there really is
no hope for you.

But since I note that you have started calling me names that I would
expect to hear from kindergarten age children, maybe the problem is
simply that you haven't grown up.
Re: using same variable twice on same page [message #171220 is a reply to message #171216] Wed, 29 December 2010 16:59 Go to previous messageGo to next message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Wed, 29 Dec 2010 09:02:17 -0700, richard <member(at)newsguy(dot)com>
wrote:

> This is totally hillarious.

Simple minds are easily amused.

> Such great minds arguing like little school boys

Does that turn you on, thinking about little school boys?

> over a minor typo which was NOT caused by MY news client.

And who said it was?
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
Re: using same variable twice on same page [message #171221 is a reply to message #171214] Wed, 29 December 2010 17:11 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/29/2010 10:21 AM, Denis McMahon wrote:
> On 29/12/10 15:10, Evan Platt wrote:
>> On Wed, 29 Dec 2010 08:19:57 -0500, Jerry Stuckle
>> <jstucklex(at)attglobal(dot)net> wrote:
>>
>>> On 12/29/2010 6:25 AM, Thomas 'PointedEars' Lahn wrote:
>>>> Adrienne Boswell wrote:
>>>>
>>>> > richard [wrote]:
>>>> >> Everything I have looked at so far talks of how to use one variable
>>>> > ONCE!
>>>> ^^
>>>> Please get a decent newsreader that does not produce broken quotes.
>>>>
>>>
>>> There is nothing wrong with his newsreader. If you see broken quotes,
>>> you need to check YOUR newsreader.
>>
>> I see broken quotes too, and I've disabled all forms of word wrap.
>>
>> Do you not see
>>
>>> Everything I have looked at so far talks of how to use one variable
>> ONCE!
>
> I looked at the message source, and there's a newline before "ONCE!",
> but no quote character after the newline. I'd call that broken quoting
> myself.
>
> Whether it was broken by the newsreader or some action of the poster is
> moot - if the poster manually inserted the newline and didn't add a
> quote character it was user action, not a broken newsreader, that led to
> the broken quoting.
>
> Rgds
>
> Denis McMahon

And that's worth bitching about? I guess it is to Pointed Head - if he
couldn't troll he'd have nothing to say.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: using same variable twice on same page [message #171223 is a reply to message #171215] Wed, 29 December 2010 17:21 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/29/2010 10:57 AM, richard wrote:
> On Wed, 29 Dec 2010 08:21:45 -0500, Jerry Stuckle wrote:
>
>> On 12/29/2010 12:07 AM, richard wrote:
>>> Everything I have looked at so far talks of how to use one variable ONCE!
>>> Nothing I've seen even comes to close as to how to utilize the same
>>> variable in a different location on the same page.
>>>
>>> for instance:
>>> initial value of $year="1960"
>>> <div> <?php echo $year;?></div>
>>> <div> blah blah blah</div>
>>> <div> yada yada yada</div>
>>> Assume here we change $year to be "1961"
>>> <div> <?php if ($year="1961") echo $year; ?></div>
>>>
>>> From what I've tried, no change is made.
>>> Even if I use a second instance of $_GET().
>>>
>>> What is the best way of doing what I want to happen?
>>>
>>> As you know, google is a hodge podge for looking up something with more
>>> than one word in the search bar.
>>
>> Richard, you really need to get a good book on php. Trying to
>> haphazardly search the internet doesn't work well. And while php.net is
>> a good reference, I don't find it to be a good learning tool. Please
>> save yourself a lot of heartache and spend a few dollars for a good book
>> to help you learn.
>>
>> As for your question - you're confusing '=' and '=='. There is a
>> difference.
>
> Jerry, I bought the PHP 5 bible ok? Like most of these damn things, it is
> so filled with gobly gook only a trained technician could understand.
> Several times he spends 10 pages on crap that has no relation to anything
> any person programming needs to know.
>
> And for you captain pukehead, I constantly read through php.net, tizag, and
> a host of others.

Actually, Richard, I've seen that book. It's a pretty decent
programming book. There is nothing in it a programmer shouldn't know.
As for having to be a "trained technician" - I haven't seen anything in
there requiring such expertise. It does, however, require a logical mind
and understanding of some very basic concepts - concepts every
successful programmer must know (like what is a "byte"?).

I'm sorry you think it's such a poor book - but you can't get a whole
lot better.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: using same variable twice on same page [message #171224 is a reply to message #171209] Wed, 29 December 2010 17:22 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 10:00:31 -0500, Jerry Stuckle wrote:

> But it's obvious Richard is trying

Indeed. Very.
Re: using same variable twice on same page [message #171225 is a reply to message #171215] Wed, 29 December 2010 17:44 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 08:57:30 -0700, richard wrote:

> I constantly read through php.net, tizag, and a host of others.

... and still don't understand the essential conceptual difference between
= and == or between a function and an array?
Re: using same variable twice on same page [message #171227 is a reply to message #171223] Wed, 29 December 2010 18:00 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, 5:21 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Actually, Richard, I've seen that book.  It's a pretty decent
> programming book.  There is nothing in it a programmer shouldn't know.
> As for having to be a "trained technician" - I haven't seen anything in
> there requiring such expertise.

I rest my case.
Re: using same variable twice on same page [message #171267 is a reply to message #171191] Wed, 29 December 2010 22:53 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 <yzhlacpa809x(dot)dlg(at)evanplatt(dot)sux>,
richard <member(at)newsguy(dot)com> wrote:

> Everything I have looked at so far talks of how to use one variable ONCE!
> Nothing I've seen even comes to close as to how to utilize the same
> variable in a different location on the same page.
>
> for instance:
> initial value of $year="1960"
> <div> <?php echo $year;?></div>
> <div> blah blah blah </div>
> <div> yada yada yada </div>
> Assume here we change $year to be "1961"
> <div> <?php if ($year="1961") echo $year; ?></div>

You have a typo in the line above.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: using same variable twice on same page [message #171270 is a reply to message #171267] Wed, 29 December 2010 23: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, 10:53 pm, Tim Streater <timstrea...@waitrose.com> wrote:
> In article <yzhlacpa809x....@evanplatt.sux>,
>
>  richard <mem...@newsguy.com> wrote:
>> Everything I have looked at so far talks of how to use one variable ONCE!
>> Nothing I've seen even comes to close as to how to utilize the same
>> variable in a different location on the same page.
>
>> for instance:
>> initial value of $year="1960"
>> <div> <?php echo $year;?></div>
>> <div> blah blah blah </div>
>> <div> yada yada yada </div>
>> Assume here we change $year to be "1961"
>> <div> <?php if ($year="1961") echo $year; ?></div>
>
> You have a typo in the line above.
Not according to Richard. He says that it is php.net that is wrong. He
can type whatever he likes. If the manual doesn't say that what he
typed is correct, it is the manual's fault.
Re: using same variable twice on same page [message #171282 is a reply to message #171196] Thu, 30 December 2010 01:07 Go to previous messageGo to next message
August Karlstrom is currently offline  August Karlstrom
Messages: 16
Registered: October 2010
Karma: 0
Junior Member
On 2010-12-29 11:42, Derek Turner wrote:
> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>
>> <?php if ($year="1961")
>
>
> This simply sets $year to "1961" and will always return 'true'

....which is more or less a flaw in the language design copied from C.

/August

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
Re: using same variable twice on same page [message #171291 is a reply to message #171282] Thu, 30 December 2010 01:31 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
August Karlstrom wrote:

> On 2010-12-29 11:42, Derek Turner wrote:
>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>> <?php if ($year="1961")
>> This simply sets $year to "1961" and will always return 'true'
>
> ...which is more or less a flaw in the language design copied from C.

Bullshit. The flaw is in script-kiddie languages like VBScript that do not
differentiate between comparison and assignment operators except for the
expression context.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Re: using same variable twice on same page [message #171299 is a reply to message #171282] Thu, 30 December 2010 04:47 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/29/2010 8:07 PM, August Karlstrom wrote:
> On 2010-12-29 11:42, Derek Turner wrote:
>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>
>>> <?php if ($year="1961")
>>
>>
>> This simply sets $year to "1961" and will always return 'true'
>
> ...which is more or less a flaw in the language design copied from C.
>
> /August
>

Not at all. == is a completely different operator than =. Just like ++
is not the same as +.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: using same variable twice on same page [message #171310 is a reply to message #171270] Thu, 30 December 2010 09:24 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Captain Paralytic wrote:
> On Dec 29, 10:53 pm, Tim Streater <timstrea...@waitrose.com> wrote:
>> In article <yzhlacpa809x....@evanplatt.sux>,
>>
>> richard <mem...@newsguy.com> wrote:
>>> Everything I have looked at so far talks of how to use one variable ONCE!
>>> Nothing I've seen even comes to close as to how to utilize the same
>>> variable in a different location on the same page.
>>> for instance:
>>> initial value of $year="1960"
>>> <div> <?php echo $year;?></div>
>>> <div> blah blah blah </div>
>>> <div> yada yada yada </div>
>>> Assume here we change $year to be "1961"
>>> <div> <?php if ($year="1961") echo $year; ?></div>
>> You have a typo in the line above.
> Not according to Richard. He says that it is php.net that is wrong. He
> can type whatever he likes. If the manual doesn't say that what he
> typed is correct, it is the manual's fault.

Took me over a day when I first tried to write assembler, to realise
that the (paper) manual had indented the code, but that the assembler
refused to accept any line beginning with white space and silently
ignored them.

I assumed from the manual, the white space was a necessary thing to
include...

This being 1982 or thereabouts, and the first micro anyone I knew had
ever seen, who could one ask?
Re: using same variable twice on same page [message #171311 is a reply to message #171282] Thu, 30 December 2010 09:26 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
August Karlstrom wrote:
> On 2010-12-29 11:42, Derek Turner wrote:
>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>
>>> <?php if ($year="1961")
>>
>>
>> This simply sets $year to "1961" and will always return 'true'
>
> ...which is more or less a flaw in the language design copied from C.
>

Which is more or less a feature of clarity,....not a flaw.

BASIC is the flawed language, allowing '=' to mean SET TO and EQUALS
according to ambiguous context

Sadly PHP copied BASICS lack of explicit typing as well.


> /August
>
Re: using same variable twice on same page [message #171320 is a reply to message #171311] Thu, 30 December 2010 10:13 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 <ifhj8t$1hd$2(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> August Karlstrom wrote:
>> On 2010-12-29 11:42, Derek Turner wrote:
>>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>>
>>>> <?php if ($year="1961")
>>>
>>> This simply sets $year to "1961" and will always return 'true'
>>
>> ...which is more or less a flaw in the language design copied from C.
>
> Which is more or less a feature of clarity,....not a flaw.
>
> BASIC is the flawed language, allowing '=' to mean SET TO and EQUALS
> according to ambiguous context
>
> Sadly PHP copied BASICS lack of explicit typing as well.

I don't want explicit typing. Let the language work for you.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: using same variable twice on same page [message #171332 is a reply to message #171320] Thu, 30 December 2010 13:05 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/30/2010 5:13 AM, Tim Streater wrote:
> In article <ifhj8t$1hd$2(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> August Karlstrom wrote:
>>> On 2010-12-29 11:42, Derek Turner wrote:
>>>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>>>
>>>> > <?php if ($year="1961")
>>>>
>>>> This simply sets $year to "1961" and will always return 'true'
>>>> ...which is more or less a flaw in the language design copied from C.
>>
>> Which is more or less a feature of clarity,....not a flaw.
>>
>> BASIC is the flawed language, allowing '=' to mean SET TO and EQUALS
>> according to ambiguous context
>>
>> Sadly PHP copied BASICS lack of explicit typing as well.
>
> I don't want explicit typing. Let the language work for you.
>

Explicit typing has many advantages - like having fewer bugs because you
can't do something stupid like pass a string where you expect an
integer. It's a big reason why you won't see large programs written in
untyped languages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: using same variable twice on same page [message #171340 is a reply to message #171282] Thu, 30 December 2010 13:35 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Thu, 30 Dec 2010 02:07:59 +0100, August Karlstrom wrote:
> On 2010-12-29 11:42, Derek Turner wrote:
>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>
>>> <?php if ($year="1961")
>>
>>
>> This simply sets $year to "1961" and will always return 'true'
>
> ...which is more or less a flaw in the language design copied from C.

.... and a correction of a flaw in any language design copied from
Fortran. We can do this all day.

--
Compared to system administration, being cursed forever is a step up.
-- Paul Tomko
OT: Assignment operator (Was: using same variable twice on same page) [message #171344 is a reply to message #171299] Thu, 30 December 2010 14:35 Go to previous messageGo to next message
August Karlstrom is currently offline  August Karlstrom
Messages: 16
Registered: October 2010
Karma: 0
Junior Member
On 2010-12-30 05:47, Jerry Stuckle wrote:
> On 12/29/2010 8:07 PM, August Karlstrom wrote:
>> On 2010-12-29 11:42, Derek Turner wrote:
>>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>>
>>>> <?php if ($year="1961")
>>>
>>> This simply sets $year to "1961" and will always return 'true'
>>
>> ...which is more or less a flaw in the language design copied from C.
>
> Not at all. == is a completely different operator than =. Just like ++
> is not the same as +.

The equal sign `=' has been used in mathematics since medieval times to
denote equality. To use `==' for equality and `=' for something else
(assignment) is not sensible.


/August

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
Re: OT: Assignment operator (Was: using same variable twice on same page) [message #171349 is a reply to message #171344] Thu, 30 December 2010 15:57 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/30/2010 9:35 AM, August Karlstrom wrote:
> On 2010-12-30 05:47, Jerry Stuckle wrote:
>> On 12/29/2010 8:07 PM, August Karlstrom wrote:
>>> On 2010-12-29 11:42, Derek Turner wrote:
>>>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>>>
>>>> > <?php if ($year="1961")
>>>>
>>>> This simply sets $year to "1961" and will always return 'true'
>>>
>>> ...which is more or less a flaw in the language design copied from C.
>>
>> Not at all. == is a completely different operator than =. Just like ++
>> is not the same as +.
>
> The equal sign `=' has been used in mathematics since medieval times to
> denote equality. To use `==' for equality and `=' for something else
> (assignment) is not sensible.
>
>
> /August
>

Programming is not mathematics.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: OT: Assignment operator (Was: using same variable twice on same page) [message #171353 is a reply to message #171344] Thu, 30 December 2010 18:36 Go to previous messageGo to next message
Jim Higgins is currently offline  Jim Higgins
Messages: 20
Registered: November 2010
Karma: 0
Junior Member
On Thu, 30 Dec 2010 15:35:10 +0100, August Karlstrom
<fusionfile(at)gmail(dot)com> wrote:

> On 2010-12-30 05:47, Jerry Stuckle wrote:
>> On 12/29/2010 8:07 PM, August Karlstrom wrote:
>>> On 2010-12-29 11:42, Derek Turner wrote:
>>>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>>>
>>>> > <?php if ($year="1961")
>>>>
>>>> This simply sets $year to "1961" and will always return 'true'
>>>
>>> ...which is more or less a flaw in the language design copied from C.
>>
>> Not at all. == is a completely different operator than =. Just like ++
>> is not the same as +.
>
> The equal sign `=' has been used in mathematics since medieval times to
> denote equality. To use `==' for equality and `=' for something else
> (assignment) is not sensible.


All fine and dandy if you're programming in BASIC, but when
programming in PHP you'll either do it as PHP requires or you'll not
get the result you expect. Sensible or not that's the way it is. Your
choice.
Re: OT: Assignment operator (Was: using same variable twice on same page) [message #171358 is a reply to message #171344] Thu, 30 December 2010 19:21 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Thu, 30 Dec 2010 15:35:10 +0100, August Karlstrom wrote:

> On 2010-12-30 05:47, Jerry Stuckle wrote:
>> On 12/29/2010 8:07 PM, August Karlstrom wrote:
>>> On 2010-12-29 11:42, Derek Turner wrote:
>>>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>>>
>>>> > <?php if ($year="1961")
>>>>
>>>> This simply sets $year to "1961" and will always return 'true'
>>>
>>> ...which is more or less a flaw in the language design copied from C.
>>
>> Not at all. == is a completely different operator than =. Just like ++
>> is not the same as +.
>
> The equal sign `=' has been used in mathematics since medieval times to
> denote equality. To use `==' for equality and `=' for something else
> (assignment) is not sensible.
>
>
> /August

Not really. As in various programming languages dictate, usage and display
can be quite different.

In BASIC and simpler low level languages, we say <>, meaning "not equal"
while in the higher level languages we say, !=.
Re: OT: Assignment operator (Was: using same variable twice on same page) [message #171360 is a reply to message #171358] Thu, 30 December 2010 19:45 Go to previous messageGo to next message
August Karlstrom is currently offline  August Karlstrom
Messages: 16
Registered: October 2010
Karma: 0
Junior Member
On 2010-12-30 20:21, richard wrote:
> On Thu, 30 Dec 2010 15:35:10 +0100, August Karlstrom wrote:
>> The equal sign `=' has been used in mathematics since medieval times to
>> denote equality. To use `==' for equality and `=' for something else
>> (assignment) is not sensible.
>
> Not really. As in various programming languages dictate, usage and display
> can be quite different.
>
> In BASIC and simpler low level languages, we say<>, meaning "not equal"
> while in the higher level languages we say, !=.

The symbols `/=' and `#' are also used in some high-level languages. It
is unfortunate that the not-equal-to sign is neither on a standard
keyboard nor in the 7-bit ASCII table. As a general guideline, however,
I don't think language designers should redefine the meaning of well
known symbols from mathematics. Or why not let `+' be the
increment-by-one operator and `++' denote addition? Why not? After all,
as Jerry Stuckle mentioned, programming is not mathematics.


/August

--
The competent programmer is fully aware of the limited size of his own
skull. He therefore approaches his task with full humility, and avoids
clever tricks like the plague. --Edsger Dijkstra
Re: OT: Assignment operator (Was: using same variable twice on same page) [message #171373 is a reply to message #171344] Thu, 30 December 2010 23:43 Go to previous messageGo to next message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma: 0
Senior Member
August Karlstrom wrote:
> On 2010-12-30 05:47, Jerry Stuckle wrote:
>> On 12/29/2010 8:07 PM, August Karlstrom wrote:
>>> On 2010-12-29 11:42, Derek Turner wrote:
>>>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>>>
>>>> > <?php if ($year="1961")
>>>>
>>>> This simply sets $year to "1961" and will always return 'true'
>>>
>>> ...which is more or less a flaw in the language design copied from C.
>>
>> Not at all. == is a completely different operator than =. Just like ++
>> is not the same as +.
>
> The equal sign `=' has been used in mathematics since medieval times to
> denote equality. To use `==' for equality and `=' for something else
> (assignment) is not sensible.
>
>
> /August
>

We've moved on since then...

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Re: using same variable twice on same page [message #171375 is a reply to message #171320] Fri, 31 December 2010 01:57 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Tim Streater wrote:
> In article <ifhj8t$1hd$2(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> August Karlstrom wrote:
>>> On 2010-12-29 11:42, Derek Turner wrote:
>>>> On Tue, 28 Dec 2010 22:07:55 -0700, richard wrote:
>>>>
>>>> > <?php if ($year="1961")
>>>>
>>>> This simply sets $year to "1961" and will always return 'true'
>>>> ...which is more or less a flaw in the language design copied from C.
>>
>> Which is more or less a feature of clarity,....not a flaw.
>>
>> BASIC is the flawed language, allowing '=' to mean SET TO and EQUALS
>> according to ambiguous context
>>
>> Sadly PHP copied BASICS lack of explicit typing as well.
>
> I don't want explicit typing. Let the language work for you.
>
I guess I am not lazy enough and prefer the language to do exactly what
I tell it.
Pages (2): [1  2    »]  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: AND in the if statement
Next Topic: login script using file, not mysql
Goto Forum:
  

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

Current Time: Sat Nov 23 01:25:15 GMT 2024

Total time taken to generate the page: 0.12663 seconds