Jump to content

Archived

This topic is now archived and is closed to further replies.

Demonic

returning more then one thing in a function?

Recommended Posts

is it this correct?

[code]
<?php
function connect($localhost,$username,$password,$database);
mysql_connect('$localhost','$username','$password') or die(mysql_error));
mysql_select_db('$database') or die(mysql_error());
return $localhost,$username,$password,$database;
}
?>
[/code]

Share this post


Link to post
Share on other sites
No.

You can only return a single value, however that value can be an array. So you could

return array($localhost,$username,$password,$database);

But in that case, having passed those values to the function and they remain unchanges in the function, where's the point in then returning them again?

Share this post


Link to post
Share on other sites
so changing what i have to:
return array($localhost,$username,$password,$database);

would work?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.