Canman2005 Posted March 10, 2009 Share Posted March 10, 2009 Hi all I have a whole chunk of PHP inserts, updates, selects etc that I need to repeat several times on the page at different places. Is there a way to mark a block of PHP code and then repeat it? Thanks Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted March 10, 2009 Share Posted March 10, 2009 Can anyone say function? Quote Link to comment Share on other sites More sharing options...
Lodius2000 Posted March 10, 2009 Share Posted March 10, 2009 or oop going with the function route though do this in your script, or in an external script and include it at the top of your script <?php function anyoldnamewilldo() { //place code block to be repeated here } // later on in the script anyoldnamewilldo(); anyoldnamewilldo(); ?> now your entire codeblock is inserted into the script twice Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 10, 2009 Share Posted March 10, 2009 and if headers are used within the function, you can add the function as require_once(); 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.