Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this message. > 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
Post Follow-up to this messageKeith 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.
Post Follow-up to this messageIn 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 > > >
Post Follow-up to this messageKeith 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.
Post Follow-up to this messageIn 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 > > >
Post Follow-up to this message. > 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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.