Well, even though it's not really about PHP, it's still a nice trick. Let's A/B test some code!
<?php /*/ $a = 1 + 1; /*/ $a = 2 + 2; /**/ echo $a . "\n";
This will print case no. 2.
If you put another asterisk (*) in the first little comment block, see what happens!
<?php /**/ $a = 1 + 1; /*/ $a = 2 + 2; /**/ echo $a . "\n";
Suddenly, this will print case no. 1!
By just putting/removing one asterisk it will toggle both cases.
I bet this will work in multiple languages. However, I didn't test it anywhere but PHP.
A little known trick that's really nice when testing out some code. Just gave it a go and worked like a charm - thanks!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Well, even though it's not really about PHP, it's still a nice trick. Let's A/B test some code!
This will print case no. 2.
If you put another asterisk (*) in the first little comment block, see what happens!
Suddenly, this will print case no. 1!
By just putting/removing one asterisk it will toggle both cases.
I bet this will work in multiple languages. However, I didn't test it anywhere but PHP.
A little known trick that's really nice when testing out some code. Just gave it a go and worked like a charm - thanks!