I first saw these on another forum and I've named them after the users that first introduced me to them. I don't know if they have another, official, name and I would be fascinated to learn whether they do.
The Jaap Comment Switch
The Jaap Comment Switch toggles two pieces of code. There is no limit to the amount of code this can hide.
Availability
This comment switch works in:
- JavaScript
- PHP
- ActionScript
- any other language that has both single-line and multi-line comments
Usage
The switch is very straight forward:
/* previous_function(); /*/ new_function(); //*/
previous_function() is completely hidden and will not fire. new_function() is active.
Switching
To switch this code, all you need to do is add a slash to the first line.
//* previous_function(); /*/ new_function(); //*/
Now, previous_function() will fire while new_function() is hidden.
The Phlip Comment Switch
The Phlip Comment Switch allows many pieces of code to be hidden and activated.
Availability
This comment switch works in:
- CSS
- JavaScript
- PHP
- ActionScript
- any other language that has multi-line comments
Usage
This comment switch requires the last line to be left alone.
/** / function_one(); /** / function_two(); /** / function_three(); /**/
In this example, all three functions are hidden.
Switching
To switch this code, remove or replace the space in the comment before the piece of code you'd like to activate or hide.
/**/ function_one(); /** / function_two(); /** / function_three(); /**/
function_one() will now fire while the other two are hidden.
Multiple code pieces can be active at the same time. For example, the following piece of code will fire function_one() and function_three() while keeping function_two() hidden.
/**/ function_one(); /** / function_two(); /**/ function_three(); /**/
Conclusion
I always find these switches useful when I'm working on a busy site, allowing me to write new code and test it while being able to replace it with the original (working) code in seconds.
I hope everyone here finds a use for these comment switches. Please feel free to reply with any other switches you've come across
Help
















