RE: [PHP] How to access any function of a any class?

pf_at_sistemasdinamicos.com.ar
Date: 03/17/05


Date: Thu, 17 Mar 2005 07:35:45 -0300 (ART)
To: "Kim Madsen" <km@comx.dk>


> Hi
>
> -----Original Message-----
> From: pf@sistemasdinamicos.com.ar [mailto:pf@sistemasdinamicos.com.ar]
> Sent: Thursday, March 17, 2005 10:04 AM
>
>> I'm sorry Kim, but it is possible, I've made a web hosting control panel
>> using entirely this approach and it is working very well for months now.
>> A
>> demo: http://cpdemo.sistemasdinamicos.com.ar/
>
> As I understood You wanted to create an instance of class a and directly
> access class Bīs functions with $A->function_from_b();
>
> THAT is only solved if Your class A inherits from B
>
> #######################################
>
> class CDominio
> {
>
> function CDominio(&$cont)
> {
> $this->ct= &$cont;
> $this->classname=get_class($this);
> }
> #
> function CreateDomain($d,$SecLevel="1",$UserType="1") /*UserType 1)
> reseller 2) user*/
> {
> $d=trim($d);
> $new_user_id=$this->ct->syf->user_uniqid(2);
> if(!$this->ct->db->query("insert into dominios (dominio, user_id) values
> ('$d', '$new_user_id')")) {
> die(gettext("Unable to insert new domain"));
> }
>
>
> ####################################################
>
>> Look how I can access any member using the container class (which has a
>> reference to every class used in the script)
>
>> For ex: $this->ct->db->query...
>> The db class contained by ct (the container)
>> or $this->ct->cr->sess
>> the cr object (another container [contained in the ct] that contains all
>> the core classes=session, authentication, security)
>
> But is it true to OOPD? No :-) Workarounds can always be made, but then
> You miss the whole concept of OOPD and all the advantages. This is not
> easy read code, right?
>
>> Perhaps I should try php5, I was told it has MUCH BETTER objects.
>
> I think You WILL run into problems with the current code in PHP5, since it
> introduces private and
> public functions.

I dont think so, because nothing is declared private in the present code.

But OOPD is not the point, nor it benefits (I found that trying to to be
complaint with EVERY specification and rule is a whole job on itself).
The point of my post was to know if somebody knows a way to use this
approach consistently, without the oddities I've found while programming.

Anyway thanks A LOT for your answers (and your time), I'll try php5 and
see what happens.

>
> But if it works for You then thatīs cool ;-)
>
> Sincerely
> Kim Madsen
>
>



Relevant Pages

  • Re: Check SLP in AD
    ... > container only. ... >> Make sure your site server computer account has Full control priviliges ... >> on the system container object and all child objects. ... >> Kim Oppalfens ...
    (microsoft.public.sms.admin)
  • Re: Bachmann Intermodal wagons
    ... > "kim" wrote ... > Intermodals tend to be semi-permanently coupled pairs of wagons whilst ... > conventional container wagons tend to be single wagons, ...
    (uk.rec.models.rail)
  • Re: Std::multisets real application
    ... why the container still present in the Standard? ... the standard only defines how the container behaves. ... S Kim ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Std::multisets real application
    ... "Mike Wahler" wrote in message ... I just wonder about the real usage of std::multiset. ... Where I /should/ use this container rather than the others? ... S Kim ...
    (alt.comp.lang.learn.c-cpp)