Home  |  Linux  | Mysql  | PHP  | XML
From:Brad LaFountain Date:Mon Mar 17 06:42:37 2003
Subject:__call for the namespaces
This idea spawned from playing with ext/rpc and the ability to declare
class types on the fly....

Since zend_namespaces is really _zend_class_entry I think it would
be cool to implement __call at the namespace level.

namespace java {
 function __call($classname) {
   // this will be called every time a new java::$classname() is called
   // and $classname isn't defined
   eval("
    class $classname {
    }
   ");
   // and it can return the new class
   return new $classname();
 }
}

This doesn't seem like it would be too hard to implement and it will allow me
to do stuff like...

<?
 $j = new java::java.util.Stack();
 // $j could be of ns java:util and class Stack
 $s = new soap::myObject("http://server/some.wsdl");
 // $s could be the namespace defined in the wsdl and of class myObject
?>

ps:
<?
namespace test {
	class test1 {
		function doSomething() {
			eval("
			class test2 { }
			");
		}
	}
}

$test1 = new test::test1();
$test1->doSomething();
?>
results in...
<b>Fatal error</b>:  Internal Zend error - Missing class information for  in
<b>
c:\php\php5\Release_TSDbg\name.php(7) : eval()'d code</b> on line <b>2</b><br
/>


 - Brad



__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com
Navigate in group php.dev at sever news.php.net
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by Zareef Ahmed
Powered By PHP Consultants