Hoorah! Had to write new text on "references" in PHP. Another example of PHP-inspired lunacy. A reference is really an alias:
$a =& $b;Now $a is an alias for $b. Kinda like *a = \$b; in Perl. And because arrays and objects are copied on assignment ...
$a = array(5, 6, 7);
$b = $a;
$a[0] = 4;
// $a is (4,6,7), $b is (5,6,7)
... constructors can't do things like build a list of objects created. Why? Because assigning the result of a constructor creates a copy:
class Person {
function Person () { // constructor
global $a;
$a[] =& $this; // build array of objs
}
}
$fred = new Person;
$fred->name = "Fred";
// $a[0]->name is not set to "Fred"
You have to say
$fred =& new Person;
Yup, you have to change how you call the constructor depending on what the constructor does behind the scenes. PTUI.--Nat
And that apparently serves as an excuse for any kind of demented design.
Re:PHP
ziggy on 2002-02-28T14:11:22
They also say "but it's easy to use".There's a lesson to be learned from PHP. I'm not sure what it is. It might just be how to market the external face of the technology to newbies (and managers). PHP proves that no amount of dementia will restrict the uptake of the technology, or the ability to attract/create core developers.
Syntax aside, I'm stunned at PHP's popularity, especially when every little extension needs to be compiled into the engine ! Perhaps that's because there are only two extensions in the world that really matter: the XML hack du jour and MySQL integration.
Re:PHP
gnat on 2002-02-28T18:13:01
That's not true--PHP supports dynamically loaded extensions.--Nat
Re:PHP
ziggy on 2002-02-28T18:19:13
Really? The few times I've set it up, there was a *long* list of extensions that could be compiled into PHP at build time. Maybe I'm confusing that with the large number of extensions that come with the standard distribution.Either case, that's good news (for next time I need to upgrade a client's PHP install).
Re:PHP
gnat on 2002-02-28T18:43:39
Yeah, the normal approach taken is to satisfy as many people as possible. That involves linking in a shitload of things so the user never has to fiddle with their php.ini file (to preload via configuration) or call the dynaloader.--Nat
Re:PHP
ziggy on 2002-02-28T19:03:55
Um, Perl doesn't have a perl.ini file, and doesn't force users to call the dynaloader. Come to think of it, neither does Python.:-) It would be an interesting study to see how user-friendly the PHP model is vs. the other way to do it. Apache seems to have inherited a config file and used it exceedingly well - modules may be compiled in or dynamically loaded, but it's really not a huge concern. (It's compiling and installing modules post-install that needs work...)
I keep trying to find areas where Perl is lacking for the average user (install, config, maintenance), but compared to what else is out there, it seems like either I have achieved Perl-mind, or Perl is really doing everything properly. I vote for the second.
:-) (But the docs, lists and websites still need some tending...) Re:PHP
belg4mit on 2002-02-28T22:25:49
Well I can tell you a few things.
a) php is lightweight, this is why I (ab)use it.
b) the function names suck (array_*?!)
c) to me it makes a good case against Highlander variables
Just yesterday I really found myself wanting to write
(explode('?', $REQUEST_URI))[0])
and ended up with
array_shift(explode('?', $REQUEST_URI)))
which isn't *too* bad I suppose.