ianric Posted March 14, 2007 Posted March 14, 2007 Hi I'm in a bored phase at the office and my mind is wandering. When I right click and view source all the code, HTML and PHP, is shown including the huge chunks I have commented out because of contribs, layout changes etc. I know it doesn't get processed but if I delete it will it make my pages run just a tiny bit faster and is it "professional" to leave the commented out chunks in the code. TIA Ian
bkellum Posted March 15, 2007 Posted March 15, 2007 Hi I'm in a bored phase at the office and my mind is wandering. When I right click and view source all the code, HTML and PHP, is shown including the huge chunks I have commented out because of contribs, layout changes etc. I know it doesn't get processed but if I delete it will it make my pages run just a tiny bit faster and is it "professional" to leave the commented out chunks in the code. TIA Ian Ian, you will thank yourself for leaving in the commented code if you ever have to troubleshoot that particular file or contribution or even add to it later on. The more comments the better is the way I see it. Bill Kellum Sounds Good Productions STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE
Guest Posted March 16, 2007 Posted March 16, 2007 Ian, you will thank yourself for leaving in the commented code if you ever have to troubleshoot that particular file or contribution or even add to it later on. The more comments the better is the way I see it. you mean it's good to have the commented out php code to show with the generated html page?
djmonkey1 Posted March 16, 2007 Posted March 16, 2007 you mean it's good to have the commented out php code to show with the generated html page? How do PHP comments show up in the generated HTML? Do, or do not. There is no try. Order Editor 5.0.6 "Ultra Violet" is now available! For support or to post comments, suggestions, etc, please visit the Order Editor support thread.
Guest Posted March 16, 2007 Posted March 16, 2007 How do PHP comments show up in the generated HTML? well if you comment php code out with html tags it will show up <tr> <td> <!-- function tep_my_secure_and_custom_password_algorithm($data, $parse) { return strtr(trim($data), $parse); } //--> </td> </tr> how's that?
vasttech Posted March 16, 2007 Posted March 16, 2007 If you are commenting out PHP code with HTML comment tags you should think twice about what you are doing. Comment PHP with PHP comment tags and HTML with HTML comment tags. Not a combination of both. People can gain a great insight into the code behind your website if you start doing it otherwise. I can tell functions and variable names instantly if you that, thus allowing me to catch them. osCommerce Knowledge Base osCommerce Documentation Contributions
usernamenone Posted March 16, 2007 Posted March 16, 2007 Quite frankly I remove all un needed code, I don't just comment it out. The faster the browser reads my site the happier I am and I am sure my browsing customer is. If the original code should ever be needed again I have the knowledge to open the original file and replace the code.
bkellum Posted March 16, 2007 Posted March 16, 2007 you mean it's good to have the commented out php code to show with the generated html page?uh....NO. It won't show up if you comment it out using PHP. Why would you comment PHP code with HTML tags??? :blink: Bill Kellum Sounds Good Productions STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE
Guest Posted March 16, 2007 Posted March 16, 2007 Sorry to chime in but I think Ian is implying that he comments out the html which is to be generated by the html. If this is the case, you should, as others have mentioned use php comment tags so that the php doesn't even have the chance to generate the html. So to get rid of: <?php if($variable = value) { echo '<html tags> and text'; } ?> comment like: <?php /* if($variable = value) { echo '<html tags> and text'; } */ ?> instead of: <?php if($variable = value) { echo '<!--- <html tags> and text ----->'; } ?>
Guest Posted March 16, 2007 Posted March 16, 2007 uh....NO. It won't show up if you comment it out using PHP. Why would you comment PHP code with HTML tags??? :blink: because that's what the original poster was asking. When I right click and view source all the code, HTML and PHP, is shown including the huge chunks I have commented out because of contribs, layout changes etc.
usernamenone Posted March 16, 2007 Posted March 16, 2007 Thank-you enigma1, And my answer is and was "yes". Yes you can remove or delete any code not need or used. You should only comment out code during development but once going live you should clean up and remove any un needed code. because that's what the original poster was asking.
djmonkey1 Posted March 16, 2007 Posted March 16, 2007 well if you comment php code out with html tags it will show up how's that? Yes, it does help if one actually reads the question, right? :) I'll also chime in and say PHP code should be commented out with PHP comments so it doesn't show up in the HTML. PHP comments for PHP and HTML comments for HTML makes the world a warm and happy place. Do, or do not. There is no try. Order Editor 5.0.6 "Ultra Violet" is now available! For support or to post comments, suggestions, etc, please visit the Order Editor support thread.
Guest Posted March 16, 2007 Posted March 16, 2007 I see, so what are the cases the html comments can be useful then? Why would you ever emit html comments in production pages. You have php where you can print out anything during testing so why using html comments at all? I am talking about the osc code, contributions, files etc.
ianric Posted March 16, 2007 Author Posted March 16, 2007 Yes, it does help if one actually reads the question, right? :) I'll also chime in and say PHP code should be commented out with PHP comments so it doesn't show up in the HTML. PHP comments for PHP and HTML comments for HTML makes the world a warm and happy place. Hi Thanks for the replies. I seem to have opened a can of worms. Oops:) The PHP chunks are commented out with // When I install a mod, the readme says find this, replace with this, so instead of replacing it I comment out the lines and paste the new code in. These don't show in the view source but where I have commented out the html cells where the stock images, surfer dude etc, show that is still seen. After almost a year of on and off development (it's a hobby so no time restrictions) there are quite a few chunks that aren't needed so I'll delete it as suggested. Many thanks Ian
Guest Posted March 16, 2007 Posted March 16, 2007 Removing the code in question is fine (backup before replacing the file :thumbsup: ). Example snippets of code are always helpful when you are asking for assistance with something like this :-" .
bkellum Posted March 16, 2007 Posted March 16, 2007 I see, so what are the cases the html comments can be useful then? Why would you ever emit html comments in production pages. You have php where you can print out anything during testing so why using html comments at all? I am talking about the osc code, contributions, files etc.Hello Mark, I am on the same page as you (total agreement) so I guess we must have misunderstood each other. I have had several headaches lately so I'm assuming it was me who misunderstood. :blush: Ian, I think it is good practise to comment out as you suggested in a development setting and it does not do any harm at all to remove the commented code for the "live" shop. I also do not see any harm in inserting one line comments in the places where you add or remove code for future reference. I do this since I work on many shops at the same time and like to keep things tidy. A lot of good "comments" on this thread alone. :lol: Bill Kellum Sounds Good Productions STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE
Recommended Posts
Archived
This topic is now archived and is closed to further replies.