Danny620 Posted September 8, 2009 Share Posted September 8, 2009 i am thinking of making a few functions to make life easiser thing is i want to know a few things say i was making a function called viewprofile this would need a $dbc & a user id would i say include the file in the function for database connections or pass it as a par say function viewprofile(){ include('datbase.php'); then use that like to do searches and things or } include('datbase.php'); then create function function viewprofile($dbc,$id){ } Link to comment https://forums.phpfreaks.com/topic/173474-few-questions-on-functions/ Share on other sites More sharing options...
RussellReal Posted September 8, 2009 Share Posted September 8, 2009 second way.. globals and other methods are really outdated and lame looking to say the least Link to comment https://forums.phpfreaks.com/topic/173474-few-questions-on-functions/#findComment-914487 Share on other sites More sharing options...
Danny620 Posted September 8, 2009 Author Share Posted September 8, 2009 so which way should i take the include inside the function or pass it as a par Link to comment https://forums.phpfreaks.com/topic/173474-few-questions-on-functions/#findComment-914601 Share on other sites More sharing options...
TeNDoLLA Posted September 8, 2009 Share Posted September 8, 2009 As RussellReal said, like you have done in the second example. Also I don't think a function dependant on includes is very good idea. Link to comment https://forums.phpfreaks.com/topic/173474-few-questions-on-functions/#findComment-914603 Share on other sites More sharing options...
Danny620 Posted September 8, 2009 Author Share Posted September 8, 2009 include('datbase.php'); then create function function viewprofile($dbc,$id){ } that way Link to comment https://forums.phpfreaks.com/topic/173474-few-questions-on-functions/#findComment-914644 Share on other sites More sharing options...
TeNDoLLA Posted September 8, 2009 Share Posted September 8, 2009 Yes. Link to comment https://forums.phpfreaks.com/topic/173474-few-questions-on-functions/#findComment-914658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.