homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

User-defined types
Clinton Labombard

 7:45 am on Nov 4, 2006 (gmt 0)

Is it possible to create user-defined types in PHP (and how do I do that) or is that something I'll get with Perl?



 3:49 pm on Nov 5, 2006 (gmt 0)

I think if maybe we have a better idea of what you are trying to do it will help us answer your question fully.

The type of a variable is usually not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which that variable is used.


Also, you may want to refer to Type Juggling [us2.php.net].

Good luck!

Clinton Labombard

 9:08 pm on Nov 6, 2006 (gmt 0)

A user-defined type defines a type defined by the user?

Okay, what it does is links some code to a variable. Here's a pseudo-code example:

myType = new Type {

myType var = "something";

..so, whenever myType is used, whatever data belonging to 'var' is passed to the subroutine belonging to 'myType'. The code can do something with that data, check it for validity, etc.


 9:11 pm on Nov 6, 2006 (gmt 0)

You confused me by saying "user-defined". I was thinking something different, and apparently everyone who read this thread did too ;)

Anyway, you are looking for Classes [us2.php.net].

That tutorial on the basics should be sufficient for now :)

Best of luck!

Clinton Labombard

 11:12 pm on Nov 7, 2006 (gmt 0)

...classes /do/ that... well slap m'fro...

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved