UCC Posted July 11, 2007 Share Posted July 11, 2007 So I of course use functions where I can; it's good coding afterall. But lets say you have a task that is as simple as Do Task X. However, you want confirmation Would you make two functions? One for the Confirmation and One to do the task? Or would you do something contained within 1 function if (isset($_POST['confirm'])) { } else { } Is one way any better than the other from a programer standpoint? Just a curiousity question that popped into my head. I usually do the latter on something simple like this. Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted July 11, 2007 Share Posted July 11, 2007 Re: Functions I only use functions for things that need doing more than once... like error checking or something Otherwise there's no point in using it, i just use if's as well, and you also dont need to declare variables as globals I doubt it'll give much performance boost either way though Quote Link to comment Share on other sites More sharing options...
hamster01 Posted August 29, 2007 Share Posted August 29, 2007 Re: Functions I find it much easier to use classes/functions. I'd make a class with misc. things like strip a string, things like that, and then make those as functions and put it in a class. Whenever I need it I just include it. I also find it very usefull when using ajax with it. And the best thing with classes, it's everywhere, and you can find things you need very easily and fast. :) Quote Link to comment Share on other sites More sharing options...
seanybob Posted August 29, 2007 Share Posted August 29, 2007 Re: Functions Psh, just use if/else statements like your example. Keeps things simple. Like somebody above me said, I only use functions for things that need to be repeated alot, such as (in mccodes) quantifying a user's items. Quote Link to comment Share on other sites More sharing options...
hamster01 Posted August 30, 2007 Share Posted August 30, 2007 Re: Functions Here is the superiority chain: Functions <- PHP - MySQL / | | Classes -> If <- Database Then the other libs come in. I mainly use it for everything, it saves allot of variable space, you write it once fluently, and then you just use it. And I did mention you can get it easily, phpclasses.org Edit: So yes.., the script I made you was if statements and not functions, but it's only for one time use. Quote Link to comment Share on other sites More sharing options...
Zeggy Posted November 11, 2007 Share Posted November 11, 2007 Re: Functions Classes != functions Classes have methods and are objects. Functions are called whenever needed in procedural programming (probably better suited in a game). Quote Link to comment Share on other sites More sharing options...
hamster01 Posted November 11, 2007 Share Posted November 11, 2007 Re: Functions Classes != functions Classes have methods and are objects. Functions are called whenever needed in procedural programming (probably better suited in a game). Wow, did you just learn that? Good work once again Einstein.. Quote Link to comment Share on other sites More sharing options...
Zeggy Posted November 11, 2007 Share Posted November 11, 2007 Re: Functions I find it much easier to use classes/functions. I'd make a class with misc. things like strip a string, things like that, and then make those as functions and put it in a class. Well, obviously you didn't know that :) Quote Link to comment Share on other sites More sharing options...
hamster01 Posted November 11, 2007 Share Posted November 11, 2007 Re: Functions I find it much easier to use classes/functions. I'd make a class with misc. things like strip a string, things like that, and then make those as functions and put it in a class. Well, obviously you didn't know that :) Sure thing mate, whatever you say.. Quote Link to comment Share on other sites More sharing options...
Guest Anonymous Posted November 11, 2007 Share Posted November 11, 2007 Re: Functions [me=LostOne]gets out the popcorn[/me] Lamo Quote Link to comment Share on other sites More sharing options...
YoungGold Posted November 12, 2007 Share Posted November 12, 2007 Re: Functions [me=LostOne]gets out the popcorn[/me] * Younggold joins Lostone with some popcorn and beers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.