[PHP-DOC] #18840 [NEW]: Problem in example of in_array()

2002-08-09 Thread ahristov

From: [EMAIL PROTECTED]
Operating system: All
PHP version:  4.2.2
PHP Bug Type: Documentation problem
Bug description:  Problem in example of in_array()

I think there is a bug in an example on the in_array()'s manual page.
Example 3:
?php
$a = array(array('p', 'h'), array('p', 'r'), 'o');

if (in_array(array ('p', 'h'), $a))
echo 'ph' is found\n;
if (in_array(array ('f', 'i'), $a))
echo 'fi' is not found\n;
if (in_array('o', $a))
echo 'o' is found\n;
?

// This will output:

'ph' is found
'o' is found

-=-=-=-=-=-
Either the message for the second if must be :
'fi' is found\n
or
the condition must be changed as well as the output
if (!in_array(array ('f', 'i'), $a))

Output:
'ph' is found
'fi' is not found
'o' is found

Regards,
Andrey
-- 
Edit bug report at http://bugs.php.net/?id=18840edit=1
-- 
Fixed in CVS:http://bugs.php.net/fix.php?id=18840r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=18840r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=18840r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=18840r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18840r=support
Expected behavior:   http://bugs.php.net/fix.php?id=18840r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18840r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18840r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=18840r=globals


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DOC] #18705 [Fbk-Opn]: More info in strstr()

2002-08-03 Thread ahristov

 ID:   18705
 User updated by:  [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
-Status:   Feedback
+Status:   Open
 Bug Type: Documentation problem
 Operating System: All
 PHP Version:  4.2.2
 New Comment:

Attention : Keep in mind that when you want whether there is substring
into string it is better to use strpos()
than to use strstr(). Most times users has problems to differentiate
the cases where the substring is found at position 0
and in the case where it is not found. 

Example 2:
$needle = I love;
$haystack = I love PHP!;
//using strstr() - bad - exhaust of memory and cpu
if (strstr($haystack, $needle)){
// found
}
//using strpos() - good no exhaust of memory
if (strpos($haystack, $needle) === TRUE){
// found
}
-=-=-=-=-= End of example.


Previous Comments:


[2002-08-02 11:43:56] [EMAIL PROTECTED]

Feel free to write the part you would like to see, submit it to this
bug, and it will hopefully (probably) be added to the documentation.



[2002-08-02 09:00:23] [EMAIL PROTECTED]

 Is it possible more information to be added to the docs of strstr()
that it is better to look if there is needle in a haystack by using
strpos() - in bold. Even small example.

Regards,
Andrey Hristov




-- 
Edit this bug report at http://bugs.php.net/?id=18705edit=1


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DOC] #18705 [NEW]: More info in strstr()

2002-08-02 Thread ahristov

From: [EMAIL PROTECTED]
Operating system: All
PHP version:  4.2.2
PHP Bug Type: Documentation problem
Bug description:  More info in strstr()

 Is it possible more information to be added to the docs of strstr() that
it is better to look if there is needle in a haystack by using strpos() -
in bold. Even small example.

Regards,
Andrey Hristov
-- 
Edit bug report at http://bugs.php.net/?id=18705edit=1
-- 
Fixed in CVS:http://bugs.php.net/fix.php?id=18705r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=18705r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=18705r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=18705r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18705r=support
Expected behavior:   http://bugs.php.net/fix.php?id=18705r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18705r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18705r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=18705r=globals


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DOC] #17556 [Com]: Docs lack specific info about switch() and continue;

2002-07-30 Thread ahristov

 ID:   17556
 Comment by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Bogus
 Bug Type: Documentation problem
 Operating System: All
 PHP Version:  4.2.1
 New Comment:

Here are two examples:
?php

$counter = 0;
while ($counter20){
switch ($counter){
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
$counter++;
break;
default:
$counter+=2;
continue;

}// swhitch
echo 'FUBAR'.[$counter]\n;
}//while

?
?php
$counter = 0;
while ($counter20){
switch ($counter){
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
$counter++;
break;
default:
$counter+=2;
continue(2);
}// switch
echo 'FUBAR'.[$counter]\n;
}// while
?
The intention is to show that there is no note in the docs for that
when programmer wants to go to the next iteration of the loop that is
shell to the switch() he/she must use continue(2); not continue;. This
is because in switch()-es continue; is equivalent to break;
In general if programmer want to skip the rest of the n-th loop
(counted from the most inner to most outter) he must use continue(n+1);
and not contunie(n);

If there is something hard to get (beacuse of my english) please
contact me and I will explain.
Regards,
Andrey Hristov


Previous Comments:


[2002-07-29 16:47:36] [EMAIL PROTECTED]

With respect to what you wanted to say, your second example is not
what you explained in your original report. Be more careful with your
wording or include an example that clarifies your report. If you
re-read your first report there is *no mention at all* of the case
where switch is inside a loop (while, for, etc.)





Also, your logic does not seem too clear to me in your example. What is
the *exact* intended effect?, perhaps that the continue goes to the
top of the while loop  even though it is *not* in the current scope of
that block but in the switch block, that will be an odd behaviour
indeed. 





If you can be:





(a) more precise w/ respect to the execution flow, 





(b) provide some examples of other scripting languages where the switch
supports a continue that behaves like you are mentioning here, 





(c) explain why such a construct is desirable instead of the more logic
one of doing a break in the switch block and perfoming the conditional
comparison outside the switch block, so you are not dependent on
side-effects (which can be tricky to debug later on)





Then there will be a good change to reopening this bug. Will wait for
your feedback, but will not reclassify this out of Bogus for the time
being.






[2002-07-29 10:11:54] [EMAIL PROTECTED]

I think that Mr Jesus Catagnetto misunsterstood what I am talking
about. IMO the bug must be reopened.

I just wanted to say that
while (some){
 switch ($foo){
   case 'bar':
if (some_reason) continue;//ie next iteration, but no, it will
increment counter after the switch. Must be continue(2);
   break;
   case 'boo':
//
   break;
   default:
   break;
 }
echo $counter++;
}



[2002-06-01 17:02:20] [EMAIL PROTECTED]

Ehem, the documentation for switch explicitly says:

... The switch statement is similar to a series of IF statements on
the same expression ...

And I do not know of any language that uses a series of if statements
as a loop construct (that is why for, while and do ... while are
there). If you know of one, I will be interesting to check it out to
see how that can be done.

Also, nowhere there is mentioned that continue can be used to loop in
a non-looping construct (e.g. if), and if you read again the the
description of continue it says:

continue is used within looping structures to skip the rest of the
current loop iteration and continue executio at the beginning of the
next iteration

thus if you use that in a context where there is no loop, it just gets
out of scope.

This is (or should) something learned in basics of programming book,
article, etc.




[2002-06-01 15:12:51] [EMAIL PROTECTED]

 After 2 years of coding in PHP I 

[PHP-DOC] #17556 [Com]: Docs lack specific info about switch() and continue;

2002-07-29 Thread ahristov

 ID:   17556
 Comment by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Bogus
 Bug Type: Documentation problem
 Operating System: All
 PHP Version:  4.2.1
 New Comment:

I think that Mr Jesus Catagnetto misunsterstood what I am talking
about. IMO the bug must be reopened.

I just wanted to say that
while (some){
 switch ($foo){
   case 'bar':
if (some_reason) continue;//ie next iteration, but no, it will
increment counter after the switch. Must be continue(2);
   break;
   case 'boo':
//
   break;
   default:
   break;
 }
echo $counter++;
}


Previous Comments:


[2002-06-01 17:02:20] [EMAIL PROTECTED]

Ehem, the documentation for switch explicitly says:

... The switch statement is similar to a series of IF statements on
the same expression ...

And I do not know of any language that uses a series of if statements
as a loop construct (that is why for, while and do ... while are
there). If you know of one, I will be interesting to check it out to
see how that can be done.

Also, nowhere there is mentioned that continue can be used to loop in
a non-looping construct (e.g. if), and if you read again the the
description of continue it says:

continue is used within looping structures to skip the rest of the
current loop iteration and continue executio at the beginning of the
next iteration

thus if you use that in a context where there is no loop, it just gets
out of scope.

This is (or should) something learned in basics of programming book,
article, etc.




[2002-06-01 15:12:51] [EMAIL PROTECTED]

 After 2 years of coding in PHP I found something strange to me but
probably not to the creators of PHP :)). continue; inside a switch
statement is equivalent of break; For this reason I've found 3 closed
bugs - 5805, 8768  7591. However there is no info in the docs that
switch() is one time loop - as said in one of the answer of one of the
reports. I think that switch() docs has to mention that switch() is
works like one iteration loop and that continue without any params
within a switch is equivalent of break;. Thus the effect which one may
want will be continue (level+1) (level is the level which will be if
the program was written in C). Finally there should be short note in
the continue; docs that inside a switch() it works somekind different
than in C and provided link to switch() page for more info.

Best regards,
Andrey Hristov




-- 
Edit this bug report at http://bugs.php.net/?id=17556edit=1


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DOC] Bug #17556: Docs lack specific info about switch() and continue;

2002-06-01 Thread ahristov

From: [EMAIL PROTECTED]
Operating system: All
PHP version:  4.2.1
PHP Bug Type: Documentation problem
Bug description:  Docs lack specific info about switch() and continue;

 After 2 years of coding in PHP I found something strange to me but
probably not to the creators of PHP :)). continue; inside a switch
statement is equivalent of break; For this reason I've found 3 closed bugs
- 5805, 8768  7591. However there is no info in the docs that switch() is
one time loop - as said in one of the answer of one of the reports. I
think that switch() docs has to mention that switch() is works like one
iteration loop and that continue without any params within a switch is
equivalent of break;. Thus the effect which one may want will be continue
(level+1) (level is the level which will be if the program was written in
C). Finally there should be short note in the continue; docs that inside a
switch() it works somekind different than in C and provided link to
switch() page for more info.

Best regards,
Andrey Hristov
-- 
Edit bug report at http://bugs.php.net/?id=17556edit=1
-- 
Fixed in CVS:http://bugs.php.net/fix.php?id=17556r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=17556r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=17556r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=17556r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17556r=support
Expected behavior:   http://bugs.php.net/fix.php?id=17556r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17556r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17556r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=17556r=globals