when will php support alias name?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yarco

    when will php support alias name?

    When using c++, we could do:
    using abc = xxx.yyy; // am i right?

    When using python we could do:
    import abc.efg as efg

    When will php support:

    class My_Best_Class
    {
    }
    define('MyClass ', 'My_Best_Class' );
    $o = new MyClass; // use MyClass as aliasname of My_Best_Class?

    It is very useful to me.
    Or do you have any good ideas to do such name alias?

  • gosha bine

    #2
    Re: when will php support alias name?

    On 24.07.2007 10:36 Yarco wrote:
    When using c++, we could do:
    using abc = xxx.yyy; // am i right?
    >
    When using python we could do:
    import abc.efg as efg
    >
    When will php support:
    >
    class My_Best_Class
    {
    }
    define('MyClass ', 'My_Best_Class' );
    $o = new MyClass; // use MyClass as aliasname of My_Best_Class?
    >
    It is very useful to me.
    Or do you have any good ideas to do such name alias?
    >
    Yes. Wait till php6 comes out. ;)


    --
    gosha bine

    makrell ~ http://www.tagarga.com/blok/makrell
    php done right ;) http://code.google.com/p/pihipi

    Comment

    • Yarco

      #3
      Re: when will php support alias name?

      Hey, friend. Do you know any good websites/forumns related to php6?
      News and details.

      On Jul 24, 4:46 pm, gosha bine <stereof...@gma il.comwrote:
      On 24.07.2007 10:36 Yarco wrote:
      >
      >
      >
      When using c++, we could do:
      using abc = xxx.yyy; // am i right?
      >
      When using python we could do:
      import abc.efg as efg
      >
      When will php support:
      >
      class My_Best_Class
      {
      }
      define('MyClass ', 'My_Best_Class' );
      $o = new MyClass; // use MyClass as aliasname of My_Best_Class?
      >
      It is very useful to me.
      Or do you have any good ideas to do such name alias?
      >
      Yes. Wait till php6 comes out. ;)
      >
      --
      gosha bine
      >
      makrell ~http://www.tagarga.com/blok/makrell
      php done right ;)http://code.google.com/p/pihipi

      Comment

      • ZeldorBlat

        #4
        Re: when will php support alias name?

        On Jul 24, 4:36 am, Yarco <yarc...@gmail. comwrote:
        When using c++, we could do:
        using abc = xxx.yyy; // am i right?
        >
        When using python we could do:
        import abc.efg as efg
        >
        When will php support:
        >
        class My_Best_Class
        {}
        >
        define('MyClass ', 'My_Best_Class' );
        $o = new MyClass; // use MyClass as aliasname of My_Best_Class?
        >
        It is very useful to me.
        Or do you have any good ideas to do such name alias?
        It sounds like you want the ability to change which class you use for
        something by just changing it in one place. So, you might have
        something like this:

        define('Databas eConnection', 'MySQLDatabaseC onnection');

        which could then later be easily changed to:

        define('Databas eConnection', 'OracleDatabase Connection');

        Without modifying the rest of your code. Is that what you're trying
        to achieve? If so you should use the factory pattern:

        class DatabaseConnect ion {

        public static function factory() {
        return new MySQLDatabaseCo nnection();
        }
        }

        class MySQLDatabaseCo nnection extends DatabaseConnect ion {

        ....

        }

        etc.

        Comment

        • Yarco

          #5
          Re: when will php support alias name?

          I find one:


          On Jul 24, 5:26 pm, Yarco <yarc...@gmail. comwrote:
          Hey, friend. Do you know any good websites/forumns related to php6?
          News and details.
          >
          On Jul 24, 4:46 pm, gosha bine <stereof...@gma il.comwrote:
          >
          On 24.07.2007 10:36 Yarco wrote:
          >
          When using c++, we could do:
          using abc = xxx.yyy; // am i right?
          >
          When using python we could do:
          import abc.efg as efg
          >
          When will php support:
          >
          class My_Best_Class
          {
          }
          define('MyClass ', 'My_Best_Class' );
          $o = new MyClass; // use MyClass as aliasname of My_Best_Class?
          >
          It is very useful to me.
          Or do you have any good ideas to do such name alias?
          >
          Yes. Wait till php6 comes out. ;)
          >
          --
          gosha bine
          >

          Comment

          • Willem Bogaerts

            #6
            Re: when will php support alias name?

            When will php support:
            >
            class My_Best_Class
            {
            }
            define('MyClass ', 'My_Best_Class' );
            $o = new MyClass; // use MyClass as aliasname of My_Best_Class?
            Never, I hope. If you cannot even trust your identifiers, all hope of
            maintaining code is gone forever.

            Especially the example is stunning. This has nothing to do with object
            orientation. If you do this the object-oriented way, you can use
            factories, interfaces and subclasses.
            Off course, a factory is a method (or a function), so you can SEE that
            it is defined elsewhere. And you can even pass it parameters.

            Best regards,
            --
            Willem Bogaerts

            Application smith
            Kratz B.V.

            Comment

            Working...