New configure option for class syntax
| From: | Sterling Hughes | Date: | Fri, 09 Jun 2000 17:26:11 +0000 |
| Subject: | New configure option for class syntax | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-20782@lists.php.net to get a copy of this message | ||
I've been contemplating for a while about the issue of PHP's namespace becoming
more and more polluted as extensions and functions continue to become added.
I think I have a solution, but at least I'd like to start a discussion on it.
Right now PHP has over 1,000 functions if you configure with all the options
set (unrealistic I know). More functions will be added, more extensions will
also be added. So what I'm thinking is to add a configure option, something
like:
./configure --with-somemodule --enable-class-somemodule
Which would then make that module use PHP's class syntax. Lets take the SWF
module for example (which has 67 functions):
If you configure:
./configure --with-swf --enable-class-swf
Then you would access the swf module like so:
$swfStream = new SWF(...); // same arguments as swf_openfile
$swfStream->ortho (...); // same arguments as swf_ortho
$swfStream->close (); // same as swf_closefile()
This way, if you wanted, you could have SWF support and save your namespace.
Ideally every module should be able to support this option, that way users
don't have to worry about a polluted namespace.
This would also be a more appetisizing syntax to some users for example when
connecting to a database you could go:
$dbh = new MySQL(
); // Same as mysql_connect
$sth = $dbh->query ("SELECT * FROM tblname"); //mysql_query
while ($row = $dbh->fetch_array ($sth)) // mysql_fetch_array
{
echo $row["name"];
}
$dbh->free_result($sth); // mysql_free_result
$dbh->close(); //mysql_close
(Anyone notice that its largely database independent=). What do people think,
any other ideas, any questions, any elaborations?
Sterling