Skip to main content

To PHP Namespace or not to PHP Namespace



ok, I'm relatively new to PHP programming and have been plodding along quite unaware that it is possible to actually use namespaces in PHP as I can in c# etc.





It's really ugly though as they have decided to use backslashes - why!?





Anyway, I am interested in other PHP programmers' views on whether namespaces will catch on in PHP and whether I should begin to use them now?



Source: Tips4all

Comments

  1. Unless all your code runs on your own servers, it's too early to start using them as 5.3 is relatively new.

    Other than that, I'm not sure if they will ever really catch on. Even classes took a long time to catch on with a large portion of the PHP programming population.

    ReplyDelete
  2. Its use is already catching on. A couple of projects use it in their upcoming/beta versions. Most examples I've seen however use it like a cargo cult. Doctrine2 for example uses five or more nested namespaces (code smell), probably to provide a 1:1 mapping of namespace/class to the filesystem/directories. I guess the novelty makes PHP namespaces prone to unreasoned overuse.

    Anyway, the syntax doesn't help with readability that much. And it's a big turn off for professional programmers. But if there is a serious use case in your project, just go for it. (Hypothetical naming conflicts are not the best reason.)

    ReplyDelete
  3. They will most likely not catch on until the core starts using them (in PHP 7 maybe possibly perhaps...), but using Python for a few months will show you that namespaces are AWESOME.

    ReplyDelete
  4. I would start learning how to use namespaces as soon as possible. Zend Framework 2.0 will use namespaces, which will mean that anyone using PHP 5.2 or lower will be out of luck. I use a virtual dedicated server, so I can control my PHP version. If you use cPanel/WHM, you can install PHP 5.3 very easily. If you are on shared hosting, it may be a little bit before you see 5.3 installed, although there are 5.3 adopters out there.

    ReplyDelete
  5. hey look up this wesite for programmers...www.countcode.com, i worked be myself for 5 months to make it run...you can share and download codes, ask or answer forum questions, and you can count your code lines from your whole life of programming, sincerely Emi

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex