TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-17-2008, 11:15 PM   #1 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default PHP Namespace Issue - What do you guys think?

Now, I don't know a whole lot about this topic, as I've not been keeping up with the Jones', as it were. I'm quite rusty in terms of PHP news, and so perhaps other people could explain it better for me. It would be appreciated!

As far as I can see, the problem with the namespaces is when there is a function inside a namespace, outside of a class, then there arises a naming problem. It was explained well to me by a friend of mine called Kalle.
  • namespace TalkPHP::Test; function Talk() {}
  • namespace TalkPHP; class Test { public function Talk() {} }

That is the problem as I see it. How does PHP know where it's going when you make the following declaration:

php Code:
use Namespace TalkPHP;
Test::Talk();

PHP would surely get confused there, and that's the problem. It wouldn't know which to call because they've allowed functions to be placed outside of classes, but inside namespaces. I don't believe other languages, such as ASP, or perhaps Java, allow that. Any items inside a namespace have to be in a class. Although I've not worked with either of those languages, so I don't know if that's true.

I personally believe that no functions should be allowed to be placed inside namespaces, without an accompanying class. It seems silly to me. Surely you'll be using namespaces in an OOP environment, and in OOP programming, I don't remember the last time I required a custom function outside of a class. Then again though, I have used static functions inside of classes to mimic namespaces, in absence of namespaces in earlier versions of PHP.

Many have suggested different characters instead of the double colon (::) to access a namespace. What do other people think to this problem, and what's the best way to overcome it, in your humble opinion?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:38 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design