473,499 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

No more access to characters in strings in PHP 6?

Just saw a message in pl.comp.lang.php, which states that the following
message has appeared in the PHP CVS snapshot:

Usage of {} to access string offsets is deprecated and will be removed
in PHP 6

What do you think of that?

Nov 22 '05 #1
10 1819
Chung Leong wrote:
Usage of {} to access string offsets is deprecated and will be removed
in PHP 6

What do you think of that?


That would be a shocker, unless they intend to go back to array-type
indexing with square brackets (deprecated as of v4). I must admit I don't
use it very often, but it's kind of a standard feature for any language,
isn't it? It would be a drag to always have to use substr(,,1).

--
E. Dronkert
Nov 22 '05 #2
On 18 Nov 2005 17:40:34 -0800, "Chung Leong" <ch***********@hotmail.com> wrote:
Just saw a message in pl.comp.lang.php, which states that the following
message has appeared in the PHP CVS snapshot:

Usage of {} to access string offsets is deprecated and will be removed
in PHP 6

What do you think of that?


So, both [] and {} access is deprecated?

http://uk.php.net/string

"String access and modification by character

Characters within strings may be accessed and modified by specifying the
zero-based offset of the desired character after the string in curly braces.

Note: For backwards compatibility, you can still use array-brackets for the
same purpose. However, this syntax is deprecated as of PHP 4. "

Or have they changed their minds and the (more sensible) array-like access is
back as the preferred method?
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Nov 22 '05 #3
Ewoud Dronkert wrote:
Chung Leong wrote:
Usage of {} to access string offsets is deprecated and will be removed
in PHP 6

What do you think of that?


That would be a shocker, unless they intend to go back to array-type
indexing with square brackets (deprecated as of v4). I must admit I don't
use it very often, but it's kind of a standard feature for any language,
isn't it? It would be a drag to always have to use substr(,,1).


What I worry about is that they'll make text string a closed structure.
If strings are to be encoded in UTF-8 internally, then they might need
to remove character-level access. I must say I really dislike the
direction PHP is heading.

Nov 22 '05 #4
no no no.

$str{} is deprecated
$str[] was deprecated but is now undeprecated

in fact $str[] will have more power than ever before:

<quote from="minutes php developers meeting"
src="http://www.php.net/~derick/meeting-notes.html#cleanup-for-vs">
1.

We will undeprecate [] for accessing characters in strings.
2.

{} will be deprecated in PHP 5.1.0 with an E_STRICT and removed
in PHP 6.
3.

For both strings and arrays, the [] operator will support
substr()/array_slice() functionality:

* [2,3] is elements (or characters) 2, 3, 4
* [2,] is elements (or characters) 2 to the end
* [,2] is elements (or characters) 0, 1, 2
* [,-2] is from the start until the last two elements in
the array/string
* [-3,2] this is the same as substr and array_slice()
* [,] doesn't work on the left side of an equation.

With these rules, the behaviour for strings will be:

* $str = "foo"; $str[] = "d"; we modify to make a
concatenation.
* $str = "fo"; $str[] = "od"; will concatenate to "food"
* $str = ""; $str[] = "d"; should become the string "d",
this should become an e_strict in 5.1.1. We need to check how common
this is first.
</quote>
Nov 26 '05 #5
Oliver Saunders said the following on 25/11/2005 23:57:
no no no.

$str{} is deprecated
$str[] was deprecated but is now undeprecated
God bless the PHP "design" committee - deprecate something, introduce a
new syntax, then deprecate the new syntax and re-introduce the old
syntax. A real step forward for the "keep the language simple" principle
that they so fervently claim to adhere to.

It sometimes seems that there's no long-term vision at all when it comes
to the development of PHP.
http://www.php.net/~derick/meeting-notes.html


There's several things described in that document which, IMO, show that
the developers are just trying to pander to novices <insert flame-war
here> and oversimplify the language by adding "features" which make
certain things superficially easier to do, but will actually end up
leading to bad coding practices in the long-run. i.e.

* The "pseudo" goto
* Adding a constructor to interface definitions - that literally makes
no sense at all.
* Late static binding - no no no, that will make people assume that
polymorphism of statics makes some kind of sense, and that it's a
sensible idea.

However, I can only applaud the plan for the removal of magic_quotes and
register_globals. :)

--
Oli
Nov 26 '05 #6
> * Adding a constructor to interface definitions - that literally makes no sense at all.

I never did really get the point of defining interfaces. Care to
enlighten me Oli?
Nov 26 '05 #7
Message-ID: <8r********************@pipex.net> from Oliver Saunders
contained the following:
$str{} is deprecated
$str[] was deprecated but is now undeprecated


Crazy. I always liked the idea of keeping array elements and string
elements separate - with novices having a hard enough time understanding
arrays as it is, any degree of separation is a good thing.

I foresee more furrowed brows in my classroom.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Nov 26 '05 #8
Oliver Saunders said the following on 26/11/2005 03:10:
* Adding a constructor to interface definitions - that literally makes
no sense at all.

I never did really get the point of defining interfaces. Care to
enlighten me Oli?

Interfaces are a kind of substitute for multiple inheritance.

Whereas traditional inheritance relates classes that are sub-classes
(i.e. more specific instances) of a base class, interfaces allow
otherwise unrelated classes to expose the same specific set of behaviours.

A good example might be an iterator; e.g.:

interface Iterator
{
public function next();
public function previous();
public function rewind();
}

class Kennel implements Iterator
{
private $dogs = array("Rex", "Fido", "Boxer");

// lots of kennel-related functions here

public function next()
{
// return next dog
}

public function previous()
{
// return previous dog
}

public function rewind()
{
// go back to start of dog list
}
}
class DataPacket implements Iterator
{
private $data = "FF:32:5C:39:01:00:A6";

// lots of packet-related functions here
public function next()
{
// return next byte
}

public function previous()
{
// return previous byte
}

public function rewind()
{
// go back to first byte in packet
}
}
Now DataPacket and Kennel objects can both be passed to any function
expecting an Iterator. The same effect could be achieved by defining a
common base class and extending Kennel and DataPacket from that, but
that wouldn't make much sense because they have nothing in common
semantically.

From a practical point of view, if DataPacket and Kennel had been
derived from a common base class, that would put severe limitations on
any other inheritance relationships, e.g. if you had wanted Kennel to be
a sub-class of Building, then you'd be screwed.
--
Oli
Nov 26 '05 #9
Geoff Berrow wrote:
Message-ID: <8r********************@pipex.net> from Oliver Saunders
contained the following:

$str{} is deprecated
$str[] was deprecated but is now undeprecated

Crazy. I always liked the idea of keeping array elements and string
elements separate - with novices having a hard enough time understanding
arrays as it is, any degree of separation is a good thing.

I foresee more furrowed brows in my classroom.


Geoff,

I think I'll have just the opposite effect. Basically it's handing a
string as an array of char, similar to C and C++.

Using the {} syntax has been quite confusing to my PHP students - why
have a special syntax just for strings? Whereas the [] syntax of C and
C++ has made understanding both strings and arrays easier for those
students.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 26 '05 #10
Message-ID: <AL******************************@comcast.com> from Jerry
Stuckle contained the following:
I foresee more furrowed brows in my classroom.


Geoff,

I think I'll have just the opposite effect. Basically it's handing a
string as an array of char, similar to C and C++.


Well I suppose that's got to be a good thing. OK, I'll reserve
judgement.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Nov 26 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2630
by: Jonathan Mcdougall | last post by:
I started using boost's filesystem library a couple of days ago. In its FAQ, it states "Wide-character names would provide an illusion of portability where portability does not in fact exist....
3
23992
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
7
8819
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
6548
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
17
30628
by: Carl Mercier | last post by:
Hi, Is it possible to use special characters like \n or \t in a VB.NET string, just like in C#? My guess is NO, but maybe there's something I don't know. If it's not possible, does anybody...
43
2177
by: ZillionDollarSadist | last post by:
Hello, I'm working at a simple Access '97 + VB4 application, and I ran into a terrible problem: something I never modified now gives me a totally unwanted "Invalid use of null" error. It happens...
4
6363
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database...
3
2256
by: sophie_newbie | last post by:
Hi, I want to store python text strings that characters like "é" "Č" in a mysql varchar text field. Now my problem is that mysql does not seem to accept these characters. I'm wondering if there...
5
15047
ADezii
by: ADezii | last post by:
Periodically, the same or similar question appears in our Access Forum: How can I use Excel Functions within Access? For this reason, I decided to make this Subject TheScripts Tip of the Week. In...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.