Skip to main content
deleted 14 characters in body
Source Link
Flonk
  • 7.8k
  • 3
  • 23
  • 25

PHP, 21 20 / 15 / 13?21

This one is doing the job using variable indirection.

$$a=$b;echo $$b?1:0;$$a=$b;!!$$b;

Most other answers don't bother to put the result to the standard outputOr, soif you could reduce this furtherdon't need it to be bool

$$a=$b;!!$$$$a=$b;$$b;

Or, ifEDIT : I forgot to handle the case where you don't need ittry to be boolcompare two empty strings, so the code now is

$$a=$b;$$$$a=$b;!($a.$b)||$$b;

which is 21 chars.

PHP, 21 20 / 15 / 13?

This one is doing the job using variable indirection.

$$a=$b;echo $$b?1:0;

Most other answers don't bother to put the result to the standard output, so you could reduce this further to

$$a=$b;!!$$b;

Or, if you don't need it to be bool

$$a=$b;$$b;

PHP, 21

This one is doing the job using variable indirection.

$$a=$b;!!$$b;

Or, if you don't need it to be bool

$$a=$b;$$b;

EDIT : I forgot to handle the case where you try to compare two empty strings, so the code now is

$$a=$b;!($a.$b)||$$b;

which is 21 chars.

added 203 characters in body
Source Link
Flonk
  • 7.8k
  • 3
  • 23
  • 25

PHP, 21 20 / 15 / 13?

This one is doing the job using variable indirection.

$$a=$b;echo $$b?1:0;

Most other answers don't bother to put the result to the standard output, so you could reduce this further to

$$a=$b;!!$$b;

Or, if you don't need it to be bool

$$a=$b;$$b;

PHP, 21 20

This one is doing the job using variable indirection.

$$a=$b;echo $$b?1:0;

PHP, 21 20 / 15 / 13?

This one is doing the job using variable indirection.

$$a=$b;echo $$b?1:0;

Most other answers don't bother to put the result to the standard output, so you could reduce this further to

$$a=$b;!!$$b;

Or, if you don't need it to be bool

$$a=$b;$$b;
Source Link
Flonk
  • 7.8k
  • 3
  • 23
  • 25

PHP, 21 20

This one is doing the job using variable indirection.

$$a=$b;echo $$b?1:0;