[PHP-DEV] Bug #12274 Updated: parser/string access problems

2001-07-21 Thread tegel

ID: 12274
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: Strings related
Operating System: NT4
PHP Version: 4.0.4pl1
New Comment:

This piece of code works correct with our system as well:
?
$s = hello ;
$s[0] = H ;
var_dump($s) ;
?


Original sourcecode generating this problem is as follows (although i can not see a 
particular difference):

 function ansi2htmlsingle($t) {
 //convert special characters from one 8-byte 
 //charset another
  for ($i=0; $istrlen($t); $i++ ) {
   $c=ord($t[$i]);
   $d=$c;
   switch ($c) {
case 138: $d=169; break; 
case 142: $d=174; break; 
case 154: $d=185; break; 
case 158: $d=190; break; 
   };
   $t[$i]=chr($d); 
  };
  return $t;  
 };

The above function is working only not for character $t[0].

This one is:

 function ansi2htmlsingle($t) {
  $r='';
  for ($i=0; $istrlen($t); $i++ ) {
   $c=ord($t[$i]);
   $d=$c;
   switch ($c) {
case 138: $d=169; break; 
case 142: $d=174; break; 
case 154: $d=185; break; 
case 158: $d=190; break; 
   };
  $r=$r.chr($d);
  };
  return $r;  
 };



Previous Comments:


[2001-07-20 22:52:51] [EMAIL PROTECTED]

BTW, I can't reproduce it with a recent CVS checkout:

[cynic@linux cynic]$ cat test.php 
?
$s = hello ;
$s[0] = H ;
var_dump($s) ;
?
[cynic@linux cynic]$ php -q test.php 
string(5) Hello
[cynic@linux cynic]$ php -v
4.0.7-dev



[2001-07-20 14:22:20] [EMAIL PROTECTED]

Oops - that should be bogus, not closed. :)



[2001-07-20 14:20:38] [EMAIL PROTECTED]

The use of brackets as to access a single character from a string is deprecated.

Use curly braces instead and you will experience the expected behavior.

i.e.
?php
$foo= 'bar';
$foo{2} = 't';
echo $foo;
?

There is additional information at 
http://www.php.net/manual/en/language.types.string.php



[2001-07-20 05:55:38] [EMAIL PROTECTED]

Suppose a string $t:
one can access(read) all single characters of $t by reading elements $t[0] .. $t[n]
Setting $t[0] however fails, setting $t[1] .. $t[n] succeeds.
Looks like when setting element [0] that $t gets converted to array type, and after 
setting $t[0] the values $t[1]..$t[n] are simply lost.

why not this behaviour with other indexes as well, only with item[0] ? - that's not 
consistent.






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


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #12274 Updated: parser/string access problems

2001-07-21 Thread tegel

ID: 12274
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: Strings related
Operating System: NT4
PHP Version: 4.0.4pl1
New Comment:


Output with second version of function:
ŽITO d.o.o. Osijek

Output with first version of function:
Warning: Undefined offset: 1 in c:\inetpub\wwwroot\info.php on line 20
Warning: Undefined offset: 2 in c:\inetpub\wwwroot\info.php on line 20
etc. etc. Elements $t[1]..$t[n] are _lost_ !

changing function to start from element $t[1] (skip first character) like for ($i=1; 
$in; $i++) and all suddenly works fine... (except for first char not get 
translated)...




Previous Comments:


[2001-07-21 04:15:14] [EMAIL PROTECTED]

This piece of code works correct with our system as well:
?
$s = hello ;
$s[0] = H ;
var_dump($s) ;
?


Original sourcecode generating this problem is as follows (although i can not see a 
particular difference):

 function ansi2htmlsingle($t) {
 //convert special characters from one 8-byte 
 //charset another
  for ($i=0; $istrlen($t); $i++ ) {
   $c=ord($t[$i]);
   $d=$c;
   switch ($c) {
case 138: $d=169; break; 
case 142: $d=174; break; 
case 154: $d=185; break; 
case 158: $d=190; break; 
   };
   $t[$i]=chr($d); 
  };
  return $t;  
 };

The above function is working only not for character $t[0].

This one is:

 function ansi2htmlsingle($t) {
  $r='';
  for ($i=0; $istrlen($t); $i++ ) {
   $c=ord($t[$i]);
   $d=$c;
   switch ($c) {
case 138: $d=169; break; 
case 142: $d=174; break; 
case 154: $d=185; break; 
case 158: $d=190; break; 
   };
  $r=$r.chr($d);
  };
  return $r;  
 };





[2001-07-20 22:52:51] [EMAIL PROTECTED]

BTW, I can't reproduce it with a recent CVS checkout:

[cynic@linux cynic]$ cat test.php 
?
$s = hello ;
$s[0] = H ;
var_dump($s) ;
?
[cynic@linux cynic]$ php -q test.php 
string(5) Hello
[cynic@linux cynic]$ php -v
4.0.7-dev



[2001-07-20 14:22:20] [EMAIL PROTECTED]

Oops - that should be bogus, not closed. :)



[2001-07-20 14:20:38] [EMAIL PROTECTED]

The use of brackets as to access a single character from a string is deprecated.

Use curly braces instead and you will experience the expected behavior.

i.e.
?php
$foo= 'bar';
$foo{2} = 't';
echo $foo;
?

There is additional information at 
http://www.php.net/manual/en/language.types.string.php



[2001-07-20 05:55:38] [EMAIL PROTECTED]

Suppose a string $t:
one can access(read) all single characters of $t by reading elements $t[0] .. $t[n]
Setting $t[0] however fails, setting $t[1] .. $t[n] succeeds.
Looks like when setting element [0] that $t gets converted to array type, and after 
setting $t[0] the values $t[1]..$t[n] are simply lost.

why not this behaviour with other indexes as well, only with item[0] ? - that's not 
consistent.






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


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #12274 Updated: parser/string access problems

2001-07-20 Thread zak

ID: 12274
Updated by: zak
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Closed
Bug Type: Strings related
Operating System: NT4
PHP Version: 4.0.4pl1
New Comment:

The use of brackets as to access a single character from a string is deprecated.

Use curly braces instead and you will experience the expected behavior.

i.e.
?php
$foo= 'bar';
$foo{2} = 't';
echo $foo;
?

There is additional information at 
http://www.php.net/manual/en/language.types.string.php

Previous Comments:


[2001-07-20 05:55:38] [EMAIL PROTECTED]

Suppose a string $t:
one can access(read) all single characters of $t by reading elements $t[0] .. $t[n]
Setting $t[0] however fails, setting $t[1] .. $t[n] succeeds.
Looks like when setting element [0] that $t gets converted to array type, and after 
setting $t[0] the values $t[1]..$t[n] are simply lost.

why not this behaviour with other indexes as well, only with item[0] ? - that's not 
consistent.






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


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #12274 Updated: parser/string access problems

2001-07-20 Thread zak

ID: 12274
Updated by: zak
Reported By: [EMAIL PROTECTED]
Old Status: Closed
Status: Bogus
Bug Type: Strings related
Operating System: NT4
PHP Version: 4.0.4pl1
New Comment:

Oops - that should be bogus, not closed. :)

Previous Comments:


[2001-07-20 14:20:38] [EMAIL PROTECTED]

The use of brackets as to access a single character from a string is deprecated.

Use curly braces instead and you will experience the expected behavior.

i.e.
?php
$foo= 'bar';
$foo{2} = 't';
echo $foo;
?

There is additional information at 
http://www.php.net/manual/en/language.types.string.php



[2001-07-20 05:55:38] [EMAIL PROTECTED]

Suppose a string $t:
one can access(read) all single characters of $t by reading elements $t[0] .. $t[n]
Setting $t[0] however fails, setting $t[1] .. $t[n] succeeds.
Looks like when setting element [0] that $t gets converted to array type, and after 
setting $t[0] the values $t[1]..$t[n] are simply lost.

why not this behaviour with other indexes as well, only with item[0] ? - that's not 
consistent.






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


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Bug #12274 Updated: parser/string access problems

2001-07-20 Thread cynic

ID: 12274
Updated by: cynic
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: Strings related
Operating System: NT4
PHP Version: 4.0.4pl1
New Comment:

BTW, I can't reproduce it with a recent CVS checkout:

[cynic@linux cynic]$ cat test.php 
?
$s = hello ;
$s[0] = H ;
var_dump($s) ;
?
[cynic@linux cynic]$ php -q test.php 
string(5) Hello
[cynic@linux cynic]$ php -v
4.0.7-dev

Previous Comments:


[2001-07-20 14:22:20] [EMAIL PROTECTED]

Oops - that should be bogus, not closed. :)



[2001-07-20 14:20:38] [EMAIL PROTECTED]

The use of brackets as to access a single character from a string is deprecated.

Use curly braces instead and you will experience the expected behavior.

i.e.
?php
$foo= 'bar';
$foo{2} = 't';
echo $foo;
?

There is additional information at 
http://www.php.net/manual/en/language.types.string.php



[2001-07-20 05:55:38] [EMAIL PROTECTED]

Suppose a string $t:
one can access(read) all single characters of $t by reading elements $t[0] .. $t[n]
Setting $t[0] however fails, setting $t[1] .. $t[n] succeeds.
Looks like when setting element [0] that $t gets converted to array type, and after 
setting $t[0] the values $t[1]..$t[n] are simply lost.

why not this behaviour with other indexes as well, only with item[0] ? - that's not 
consistent.






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


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]