User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 4 Aug 2003, 14:42   #1
Mong
Forever Delayed
 
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
Mong is on a distinguished road
Returning PHP values from functions.

I've not slept for days, so my brain is rotting. Anything wrong with this? I can't get $img back from the function...

Code:
function doImg ($title, $level, $img)
{

	if ($level == 4)
	{
		$img = $title.'-raog.gif';
	}
	elseif ($level == 3)
	{
		$img = $title.'-rao.gif';
	}
	elseif ($level == 2)
	{
		$img = $title.'-ra.gif';
	}
	else
	{
		$img = $title.'-r.gif';
	}
	return $img;

}

doImg('test', 1, $img);

echo '<img src=img/'.$img.'>';
Cheers,

M.
__________________
Firefly Oper and General l4m3r - "I Do Stuff"

O2 Rip-off campaign

<vampy> plus i hate people ... i despise humanity as a whole

pablissimo "I'm still geting over the fact you just posted a pic of your own vomit"
Mong is offline   Reply With Quote
Unread 4 Aug 2003, 14:46   #2
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Either use
Code:
$img=doImg('test', 1, $img);
(preferred)


Or pass by reference to get the semantics you seem to want:
Code:
function doImg ($title, $level, &$img)
__________________
#linux
queball is offline   Reply With Quote
Unread 4 Aug 2003, 14:49   #3
Mong
Forever Delayed
 
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
Mong is on a distinguished road
Quote:
Originally posted by queball
Either use
Code:
$img=doImg('test', 1, $img);
(preferred)[/code]
Goddamnitalltohell! Like I said, my brain is asleep today, I'm on auto.

Quote:
Originally posted by queball
Or pass by reference to get the semantics you seem to want:
Code:
function doImg ($title, $level, &$img)
Passing by reference in PHP is something I avoid wherever possible

Ta,

M.
__________________
Firefly Oper and General l4m3r - "I Do Stuff"

O2 Rip-off campaign

<vampy> plus i hate people ... i despise humanity as a whole

pablissimo "I'm still geting over the fact you just posted a pic of your own vomit"
Mong is offline   Reply With Quote
Unread 4 Aug 2003, 14:58   #4
Mong
Forever Delayed
 
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
Mong is on a distinguished road
Many thanks, my entirely pointless and self-indulgent thingie is working now

You think this is excessive? It uses a MySQL DB... surely that's entirely reasonable?

M.
__________________
Firefly Oper and General l4m3r - "I Do Stuff"

O2 Rip-off campaign

<vampy> plus i hate people ... i despise humanity as a whole

pablissimo "I'm still geting over the fact you just posted a pic of your own vomit"
Mong is offline   Reply With Quote
Unread 4 Aug 2003, 15:09   #5
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Quote:
Originally posted by Mong
Many thanks, my entirely pointless and self-indulgent thingie is working now

You think this is excessive? It uses a MySQL DB... surely that's entirely reasonable?

M.
Very "Kevin Warwick"
queball is offline   Reply With Quote
Unread 4 Aug 2003, 15:14   #6
Mong
Forever Delayed
 
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
Mong is on a distinguished road
Quote:
Originally posted by queball
Very "Kevin Warwick"
Who?
__________________
Firefly Oper and General l4m3r - "I Do Stuff"

O2 Rip-off campaign

<vampy> plus i hate people ... i despise humanity as a whole

pablissimo "I'm still geting over the fact you just posted a pic of your own vomit"
Mong is offline   Reply With Quote
Unread 4 Aug 2003, 15:31   #7
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Quote:
Originally posted by Mong
Who?
:-/


http://www.cyber.rdg.ac.uk/news/index.htm?00045

Perhaps very "Simon Tegala"?
http://www.iniva.org/anabiosis/body/body_feb27.html

Though I suppose this sort of thing is common on blogs and IMs these days. Crazy kids.
queball is offline   Reply With Quote
Unread 4 Aug 2003, 16:36   #8
Mong
Forever Delayed
 
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
Mong is on a distinguished road
I've never seen this kinda thing before... assumed I was being original

M.
__________________
Firefly Oper and General l4m3r - "I Do Stuff"

O2 Rip-off campaign

<vampy> plus i hate people ... i despise humanity as a whole

pablissimo "I'm still geting over the fact you just posted a pic of your own vomit"
Mong is offline   Reply With Quote
Unread 4 Aug 2003, 16:47   #9
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
Quote:
Originally posted by Mong
I've never seen this kinda thing before... assumed I was being original
Well, "happy" or "unhappy" icons.

MySQL certainly isn't overkill. I can't think of a better protocol for transferring the data from your cybernetic implants to the web.
queball is offline   Reply With Quote
Unread 13 Aug 2003, 10:37   #10
Coffee
Ensign
 
Coffee's Avatar
 
Join Date: Apr 2000
Location: An intricate fantasy world.
Posts: 166
Coffee is an unknown quantity at this point
Code:
function doImg ( $title, $level )
{

	switch ( $level ) {
	case 4:
		$img = $title.'-raog.gif';
		break;
	case 3:
		$img = $title.'-rao.gif';
		break;
	case 2:
		$img = $title.'-ra.gif';
		break;
	default:
		$img = $title.'-r.gif';
	}

	return $img;

}

$img = doImg ( 'test', 1 );

echo '<img src="img/'.$img.'">';
Is probably better...
__________________
PIE*

Last edited by Coffee; 14 Aug 2003 at 10:15.
Coffee is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 09:20.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018