note 82088 modified in language.namespaces.using by danbrown

From: Date: Tue, 09 Dec 2008 05:00:40 +0000
Subject: note 82088 modified in language.namespaces.using by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147936@lists.php.net to get a copy of this message
Syntax for extending classes in namespaces is still the same. Lets call this Object.php: <?php namespace com::rsumilang::common; class Object{ // ... code ... } ?> And now lets create a class called String that extends object in String.php: <?php class String extends com::rsumilang::common::Object{ // ... code ... } ?> Now if you class String was defined in the same namespace as Object then you don't have to specify a full namespace path: <?php namespace com::rsumilang::common; class String extends Object { // ... code ... } ?> Lastly, you can also alias a namespace name to use a shorter name for the class you are extending incase your class is in seperate namespace: <?php namespace com::rsumilang::util; use com::rsumlang::common as Common; class String extends Common::Object { // ... code ... } ?> - Richard Sumilang --was-- Syntax for extending classes in namespaces is still the same. Lets call this Object.php: <?php namespace com::rsumilang::common; class Object{ // ... code ... } ?> And now lets create a class called String that extends object in String.php: <?php class String extends com::rsumilang::common::Object{ // ... code ... } ?> Now if you class String was defined in the same namespace as Object then you don't have to specify a full namespace path: <?php namespace com::rsumilang::common; class String extends Object { // ... code ... } ?> Lastly, you can also alias a namespace name to use a shorter name for the class you are extending incase your class is in seperate namespace: <?php namespace com::rsumilang::util; use com::rsumlang::common as Common; class String extends Common::Object { // ... code ... } ?> - Richard Sumilang http://php.net/manual/en/language.namespaces.using.php

« previous php.notes (#147936) next »