1

Is there any possible way to get this working:

What is the best comment in source code you have ever encountered? (which I think is C++, but I have no idea)

...working in PHP? I'd love to mess with my co-workers as a little prank and see what happens ;)

Community
  • 1
  • 1
Scott
  • 5,338
  • 5
  • 45
  • 70

2 Answers2

1

No. There's not.

PHP doesn't have a preprocessor (strictly speaking, it is the preprocessor!); within its scope, keywords trump constants.

A C++ "trick" like this:

#define true false

works because the preprocessor manipulates the code on a context-less basis... though it should be noted that the standard makes that "trick" illegal (strictly speaking, "undefined").

The scenario is a little different in C, but the general principle isn't much different.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
1

You can't. Even though you will not get an error message for this since define does not check the list of reserved words, it will not work. Boolean values are globally defined in PHP.

See http://www.php.net/manual/en/function.define.php and http://bugs.php.net/bug.php?id=13505 for more infos.

grundprinzip
  • 2,471
  • 1
  • 20
  • 34