+ Reply to Thread
Results 1 to 1 of 1

Thread: How can I Instatiante objects dynamically in PHP?

  1. #1
    clareto is offline x10 Sophmore clareto is an unknown quantity at this point
    Join Date
    Oct 2005
    Posts
    125

    How can I Instatiante objects dynamically in PHP?

    I have a question:
    Is there any way to reference a class?
    For example, I dont want to create an object until I make use of it. So I would like to have something like an ObjectManager that would return me an object when I request it.

    the ideal code would be

    PHP Code:
    class classA{
     
    //code here
    }

    class 
    classB{
     
    //code here
    }

    class 
    ObjectManager{
     
    //methods and fields of ObjectManager
    }

    $myObjectManager = new ObjectManager();

    $myObjectManager->RegisterClass(classA);
    $myObjectManager->RegisterClass(classB);

    $objectOfClassA $myObjectManager->GetObject('class A');
    $objectOfClassB $myObjectManager->GetObject('class B'); 
    [[If you got the idea and have a different technique to achieve it, please...]]


    By the way, whats the difference of using
    new ObjectManager;
    and
    new ObjectManager();
    ???
    thanks.
    Last edited by clareto; 01-06-2007 at 12:01 PM. Reason: code was not wrapped in [php] tags

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  4. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  5. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers