News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHP in Action Blog:
I want enums in PHP
May 12, 2008 @ 08:41:16

I want Enums in PHP

That's how this new post on the PHP in Action blog starts this morning. The one thing that he wants is enumeration support in PHP. He shows how it can currently come close with a "roles" system:

Useful examples I've encountered in web programming are states or stages in a process and user roles. Another kind of example is one I used in PHP In Action: an authorization system with three fixed roles or categories of user: regular, webmaster and administrator.

He sets up an example class that sets constants for the different access levels rather than just relying on strings to handle it (which, as he points out, could very easily be misspelled and not throw any kind of error) .

2 comments voice your opinion now!
enumeraction enum phpinaction multiple value constant


blog comments powered by Disqus

Similar Posts

PHPBuilder.com: Transfer Data via Multiple Protocols with Libcurl

Joshua Thijssen's Blog: LAMP-stack? Forget it! Itís a LAMPGMVNMCSTRAH-stack now...

WebReference.com: The Building Blocks: Data Types, Literals, Variables, and Constants - Part 3

Giorgio Sironi's Blog: PHP in Action review

Bill Staples' Blog: IIS7 Patch for Windows Vista fixes CGI/PHP apps - multiple response headers


Community Events





Don't see your event here?
Let us know!


symfony laravel release configure list framework conference community interview api podcast unittest series introduction opinion composer version language voicesoftheelephpant threedevsandamaybe

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework