Jump to content

returning more then one thing in a function?


Demonic

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]
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?

Archived

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

×
×
  • Create New...

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.