Some more 'Bug or features'

[email protected] ("Jeroen")
Newsgroups php.lang
Message-ID <066d01c0dfca$0382b760$0400000a@giga>
Hi,

While updating language-doc I ran into some 'bug or feature' things.

I'm not at all a zend-developper (I don't like C too much, but that's
obviously not the only reason ;),
so I'm not at all sure of anything I state below.

I planned to either not document these at all, or define it as undocumented
behaviour / deprecated behaviour.

(a)- Negative integer array-indices
(b)- arrayindices with something else than strings or integers.
(c)- the ++/-- operator with strings. (the goes well in a the simpelest
cases, but in many it goes goes wrong,
so I.M.O it's best to disencourage its use.
Although, I'm not sure about this...
Some strange behaviour is this:
(pseudo-code of course)

++'001' = '002' (okay)
++'99' = '100' (okay)
++' 99' = ' 00' (hmm...)
++'abc' = 'abd'
++'xyz' = 'xza' (great, counting in letters :)
++'9.9' = '9.0'
++'-3'  = '-4'
--'9'   = 8 (integer!)
--'5.5' = '5.5'
--'-9'  = -10 (integer)
--'09'  = 8 (integer)
--'abc' = 'abc'

First, ++ and -- behave quite differently. Secondly, the ++-implementation
works only well with straight integer
numbers, they may even contain leading zero's which will be maintained.

(d)- function func(const $param)
Why does this exist anyway?

(e)- cast arrays to int/float
( logic behaviour i.m.o. is returning the number of elements, it's more
useful than 0/1 based on empty/nonempty. )

(f)- use of functions inside some string-constructions.
echo "bla bla ${ func('para') } bla bla";

And I'm thinking about declaring:
(g)- use of "  ${identifier} "
as deprecated
(php3-legacy, preferred way is " {$identifier} ")
Note: I not so sure about defining this as deprecated...
Because ${identifier} looks too much like ${expr} outside strings.
I know, the same applies to "$arr[identifier]" vs. $arr[expr] ,
and that's definitely something you want to keep.


That's it for now...

Greetz,
Jeroen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.