Creating objects from php extensions
| From: | Klaus Reimer | Date: | Mon, 03 Apr 2000 13:35:44 +0000 |
| Subject: | Creating objects from php extensions | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-13036@lists.php.net to get a copy of this message | ||
Hi,
It seems to be possible to return an object with properties and methods from a
php function written in C (found in apidoc.txt, Chapter 8). But how can I define
an object WITHOUT calling a function. I want to do something like:
<?php
dl("myextension.so");
$myclass=new CMyClass;
$myclass->do_something();
?>
CMyClass is an object provided by myextension.so. But how can I do that? I need
that for a self-defined class performing some database-related stuff. The
constructor opens a database connection and the methods are using it:
$MyDBStuff=new CMyDBStudd; // Constructor opens database connection;
$MyDBStuff->readSometing(); // Uses opened database connection;
$myDBStuff->readOtherThings(); // Uses opened database connection, too;
And remember: I want that class be written in C, not PHP. I know how to write
simple PHP extensions in C(++), but I can't find any hint how to create a PHP
class in C, without calling a function returning the class as return_value.
By the way: Is there no destructor in PHP classes?
Bye
K