nEJC Posted August 2, 2008 Share Posted August 2, 2008 I want to do a bunch of code snippets where I could get the same information no matter if it was executed from included code or called with AJAX. Let me put out my idea - I'd love to hear your comments. I hope this proto code is understandable function get_data( $isAJAX, $param1, $param2 ) { do the magic to get $data if( $isAJAX ) echo ajax wrapped $data else echo $data } if( !defined('TOP') ) { we have ajax call, parse $GET get_data( TRUE, $1, $2 ) } If code would be used with include all I'd have to do is call the same function with first parameter as FALSE. What do you think? Quote Link to comment https://forums.phpfreaks.com/topic/117877-reusable-code-in-include_once-and-ajax/ Share on other sites More sharing options...
Daniel0 Posted August 3, 2008 Share Posted August 3, 2008 I'm not quite sure what the code is for. Also, for a function called get*() I'd expect it to return data, not output it. If code would be used with include all I'd have to do is call the same function with first parameter as FALSE. I don't understand what you mean. All include() (and require()) does is that it starts evaluating another file at the point where the call to include() is. I hope this proto code is understandable You usually call such code pseudocode. Just saying Quote Link to comment https://forums.phpfreaks.com/topic/117877-reusable-code-in-include_once-and-ajax/#findComment-606696 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.