Class returning more than one value

This is a discussion on Class returning more than one value within the PHP General forums, part of the PHP Programming Forums category; Hi, How can i code a class with a function that returns more than one value ? Any help would be ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-14-2006
Deckard
 
Posts: n/a
Default Class returning more than one value

Hi,

How can i code a class with a function that returns more than one value ?

Any help would be appreciated.

Warm Regards,
Deckard
Reply With Quote
  #2 (permalink)  
Old 10-14-2006
Paul Scott
 
Posts: n/a
Default Re: [PHP] Class returning more than one value


On Sat, 2006-10-14 at 11:06 +0100, Deckard wrote:
> How can i code a class with a function that returns more than one value ?
>


1. return array();
2. return stdClass;

--Paul


All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/...imer/index.htm

Reply With Quote
  #3 (permalink)  
Old 10-15-2006
Sumeet
 
Posts: n/a
Default Re: [PHP] Class returning more than one value

Paul Scott wrote:
> On Sat, 2006-10-14 at 11:06 +0100, Deckard wrote:
>> How can i code a class with a function that returns more than one value ?
>>

>
> 1. return array();
> 2. return stdClass;
>
> --Paul
>


another option.. can be avoid, is to use global variables or
references...and modify them in the function

--
Thanking You

Sumeet Shroff
http://www.prateeksha.com
Web Designers and PHP / Mysql Ecommerce Development, Mumbai India
Reply With Quote
  #4 (permalink)  
Old 10-15-2006
bob.chatman@gmail.com
 
Posts: n/a
Default Re: Class returning more than one value

Actually, probably the better way to keep variables seperate, is
reference variables.

Using globals works, yes, but its not going to be as easy to read whats
going on.

http://us3.php.net/manual/en/languag...ences.pass.php

Pass in a variable by reference, change the value bling bloop you get
as many variables returned without having to write bad code.

Bob

Sumeet wrote:
> Paul Scott wrote:
> > On Sat, 2006-10-14 at 11:06 +0100, Deckard wrote:
> >> How can i code a class with a function that returns more than one value ?
> >>

> >
> > 1. return array();
> > 2. return stdClass;
> >
> > --Paul
> >

>
> another option.. can be avoid, is to use global variables or
> references...and modify them in the function
>
> --
> Thanking You
>
> Sumeet Shroff
> http://www.prateeksha.com
> Web Designers and PHP / Mysql Ecommerce Development, Mumbai India


Reply With Quote
  #5 (permalink)  
Old 10-16-2006
Richard Lynch
 
Posts: n/a
Default Re: [PHP] Class returning more than one value

On Sat, October 14, 2006 5:06 am, Deckard wrote:
> How can i code a class with a function that returns more than one
> value ?


Classes do not return values.

Functions return values.

Class methods (which are very much like functions) return values.

In PHP, functions/methods do not return more than one value.

You must wrap your multiple values up into some kind of more complex
(non-scalar) structure.

An array or an instance of a class will both work fine.

Which one is appropriate depends on the existing application,
framework, and personal religious convictions of code develoment.

YMMV

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Reply With Quote
Reply
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

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



All times are GMT +1. The time now is 08:50 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0