note 82088 added to language.namespaces.using
| From: | richard at richard-sumilang dot com | Date: | Thu, 27 Mar 2008 09:36:28 +0000 |
| Subject: | note 82088 added to language.namespaces.using | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137624@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
----
Server IP: 208.69.120.35
Probable Submitter: 24.24.191.132
----
Manual Page -- http://www.php.net/manual/en/language.namespaces.using.php
Edit -- https://master.php.net/note/edit/82088
Del: integrated -- https://master.php.net/note/delete/82088/integrated
Del: useless -- https://master.php.net/note/delete/82088/useless
Del: bad code -- https://master.php.net/note/delete/82088/bad+code
Del: spam -- https://master.php.net/note/delete/82088/spam
Del: non-english -- https://master.php.net/note/delete/82088/non-english
Del: in docs -- https://master.php.net/note/delete/82088/in+docs
Del: other reasons-- https://master.php.net/note/delete/82088
Reject -- https://master.php.net/note/reject/82088
Search -- https://master.php.net/manage/user-notes.php