Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #19054
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Arno Welzel <usenet@arnowelzel.de> |
| Newsgroups | comp.lang.php |
| Subject | Re: Always use class aliases? |
| Date | Sun, 10 Jul 2022 04:39:43 +0200 |
| Lines | 40 |
| Message-ID | <jiusffFa913U1@mid.individual.net> (permalink) |
| References | <t9rjld$tja$1@gioia.aioe.org> <jim11eFs1maU1@mid.individual.net> <ta6a21$pqn$1@gioia.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net 99Ejd085iUbRKU0HaKxpFwGPB5mRlLOPzQlC59JIiiodzuH9qw |
| Cancel-Lock | sha1:dp8Wa+gOPeMa60x1NUmvzY7VNJs= |
| Content-Language | de-DE |
| In-Reply-To | <ta6a21$pqn$1@gioia.aioe.org> |
| Xref | csiph.com comp.lang.php:19054 |
Show key headers only | View raw
Flash: > Il 06/07/22 20:02, Arno Welzel ha scritto: >> This makes no sense at all. You don't need an alias if you use the class >> at it is: >> >> <?php >> use MyClass; > > > ~$ php -r 'use stdClass;' > > Warning: The use statement with non-compound name 'stdClass' has no > effect in Command line code on line 1 Yes, I forgot that you need the namespace as well, either defined in the use statement: <?php use SomeNamespace\MyClass; Or in your code: <?php namespace SomeNamespace; use MyClass; But then you don't have to add an alias if you want to use the class as "MyClass", so - this is not needed: <?php use SomeNamespace\MyClass as MyClass; Also see <https://www.php.net/manual/en/language.namespaces.importing.php> -- Arno Welzel https://arnowelzel.de
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Always use class aliases? Flash <new@flash.foto> - 2022-07-03 10:23 +0200
Re: Always use class aliases? Ace of diamonds <he12091983@gmail.com> - 2022-07-06 09:19 -0700
Re: Always use class aliases? De ongekruisigde <ongekruisigde@news.eternal-september.org> - 2022-07-07 11:35 +0000
Re: Always use class aliases? Arno Welzel <usenet@arnowelzel.de> - 2022-07-06 20:02 +0200
Re: Always use class aliases? Flash <new@flash.foto> - 2022-07-07 11:46 +0200
Re: Always use class aliases? Arno Welzel <usenet@arnowelzel.de> - 2022-07-10 04:39 +0200
Re: Always use class aliases? "He, who travels time to time" <he1983912@aol.com> - 2022-09-22 07:13 -0700
csiph-web