Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member hagen's Avatar
    Join Date
    Aug 2005
    Posts
    408
    Member #
    10882
    Liked
    1 times
    Hiya, does anyone have the neatest way to create / represent a type class in PHP?

    I think that what I want?

    IE say a variable say $animal, with the possible values: cat, chicken, horse, lizard...

    Thank you :-)
    Hagen Rose: hagen(at)jxwd(dot)co(dot)uk
    JX Web Development, Bournemouth, Dorset...JXWD.co.uk

  2.  

  3. #2
    Junior Member cpowell89's Avatar
    Join Date
    Dec 2012
    Location
    England
    Posts
    6
    Member #
    34201
    Could you explain what you mean a little bit more? When you say a type class/variable do you mean e.g.

    int $myvariable or string $myvariable. As in casting a type to a variable/class?

  4. #3
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    Late reply, looks like what you're after is how to make a 'struct' or an 'enum' in PHP which is just representing it with class constants, statically available. Lots of answers to this problem, i.e.

    http://stackoverflow.com/questions/254514/php-and-enums

    has some good answers.
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:41 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com