Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

php4 (variable scope)
Seasons greetings NG,

I have a php4/mysql4/iis6 setup.

I have several applications running on the above platform..  We selected the
platform for a number of reasons one of which was the availability of the C
(98?) language.  .We have come across an issue I cannot explain, I wonder if
anyone has any insights? To cut to the chase  when we query the database &
return more than 9000 rows we cannot get scripts to execute & behave as we
expect.  Regardless of the number of  rows returned execution only occurs
for one iteration if the number of  rows returned is greater the 9000. After
some investigation  we found that it was an issue with variable scope. A
truncated example follows:

//query database,  get the data etc
//...script is executing
//someValue is greater than 9000

for$i=0;$i<someValue;++$i{
//do something
}

//redeclare $i, IMO first $i should be out of scope
for$i=0;$i<someValue;++$i{
//do something
}

...rest of execution

renaming $i in the 2nd scope to any other name not in the script so that
each control variable has a unique  name appears to solve the problem.
However I was under  the impression that my redeclaration of $i in my second
scope  was legal. Assuming I am incorrect & it is illegal; the 9000 rows
value I assume is simply UB?

TIA
Keith



Report this thread to moderator Post Follow-up to this message
Old Post
Keith R
12-23-04 08:58 PM


Re: php4 (variable scope)
.
> However I was under  the impression that my redeclaration of $i in my
> second scope  was legal.

I  am now aware that my declaration(s)  of $i for the C90 standard  neither
declaration is legal.  For C99, both are. This leads me  to ask which C
standard is php4 based upon?

Regards,
Keith




Report this thread to moderator Post Follow-up to this message
Old Post
Keith R
12-23-04 08:58 PM


Re: php4 (variable scope)
Keith R spilled the following:

>
> . 
>
> I  am now aware that my declaration(s)  of $i for the C90 standard
> neither
> declaration is legal.  For C99, both are. This leads me  to ask which C
> standard is php4 based upon?
>
> Regards,
> Keith

PHP is not C, never has been, never will.

The code you published will not run in PHP

The code you will not compile with C

(both languages require the 'for' construct's parameters to be enclosed in
brackets:
for ($i=1; $i<$some_value;$i++) { // for PHP
for (i=1; i<some_value; i++) { // for C
)

...and C90 is a standard for audio cassettes, not programming languages.
Although C90 has been used as nickname for ISO/IEC 9989:1990 it's unlikely
that most people reading this newsgroup would be aware of that.

...oh and even if the code did behave as you say it does - that's not a
scope issue.

Want to try again?

C.


Report this thread to moderator Post Follow-up to this message
Old Post
Colin McKinnon
12-24-04 01:56 AM


Re: php4 (variable scope)
In PHP, one does not declare variables, it is perfectly acceptable to
use $i as you are doing; the PHP interpreter deals with it all.

PHP isn't based on any C standard, it just has some syntax in common,
but then so does Java, JavaScript, etc...

Can you post a more in-depth code sample, to show us what you're
actually doing with the MySQL results, etc.?

Oli

Keith R wrote:
> .
> 
>
>
> I  am now aware that my declaration(s)  of $i for the C90 standard  neithe
r
> declaration is legal.  For C99, both are. This leads me  to ask which C
> standard is php4 based upon?
>
> Regards,
> Keith
>
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
Oli Filth
12-24-04 01:56 AM


Re: php4 (variable scope)
Keith R spilled the following:

>
> . 
>
> I  am now aware that my declaration(s)  of $i for the C90 standard
> neither
> declaration is legal.  For C99, both are. This leads me  to ask which C
> standard is php4 based upon?
>
> Regards,
> Keith

PHP is not C, never has been, never will.

The code you published will not run in PHP

The code you will not compile with C

(both languages require the 'for' construct's parameters to be enclosed in
brackets:
for ($i=1; $i<$some_value;$i++) { // for PHP
for (i=1; i<some_value; i++) { // for C
)

...and C90 is a standard for audio cassettes, not programming languages.
Although C90 has been used as nickname for ISO/IEC 9989:1990 it's unlikely
that most people reading this newsgroup would be aware of that.

...oh and even if the code did behave as you say it does - that's not a
scope issue.

Want to try again?

C.


Report this thread to moderator Post Follow-up to this message
Old Post
Colin McKinnon
12-28-04 01:59 PM


Re: php4 (variable scope)
In PHP, one does not declare variables, it is perfectly acceptable to
use $i as you are doing; the PHP interpreter deals with it all.

PHP isn't based on any C standard, it just has some syntax in common,
but then so does Java, JavaScript, etc...

Can you post a more in-depth code sample, to show us what you're
actually doing with the MySQL results, etc.?

Oli

Keith R wrote:
> .
> 
>
>
> I  am now aware that my declaration(s)  of $i for the C90 standard  neithe
r
> declaration is legal.  For C99, both are. This leads me  to ask which C
> standard is php4 based upon?
>
> Regards,
> Keith
>
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
Oli Filth
12-28-04 01:59 PM


Re: php4 (variable scope)
.
> However I was under  the impression that my redeclaration of $i in my
> second scope  was legal.

I  am now aware that my declaration(s)  of $i for the C90 standard  neither
declaration is legal.  For C99, both are. This leads me  to ask which C
standard is php4 based upon?

Regards,
Keith




Report this thread to moderator Post Follow-up to this message
Old Post
Keith R
12-28-04 08:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:53 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.