$a{} stuff
| From: | Derick Rethans | Date: | Sat, 03 Jan 2004 21:35:51 +0000 |
| Subject: | $a{} stuff | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-6777@lists.php.net to get a copy of this message | ||
Hello,
due to a little discussion on IRC I noticed that the following code
works:
<?php
$a = "foobar";
$a{strlen($a)-1};
?>
now IMO the offset should only be a simple integer value, as this is a
little bit too much magic to me (and perlish). Although the code above
can have it's use, the following does also work fine:
file1.php
<?php
return 4;
?>
file2.php
<?php
$a = "foobar";
echo $a{include 'file1.php'};
?>
echos 'a'.
I think this sideeffect should be disallowed as it adds a lot of
unreadableness to code. (I do als vagely remember a discussion a year or
something ago which resulted in something like "the offset to a string
should be an integer only, and not for example {1..4} or {-1}". Can't
find this though in the archives.
regards,
Derick