Penguin
The "?:", or Ternary operator in PHP, Java, Perl, C and possibly other languages is essentially shorthand for a block of code like

if ($a==1) {

print "A is 1!";

} else {

print "A is not 1!";

}

Using the ternary operator, it becomes
print ($a==1) ? "A is 1!" : "A is not 1!";

Cool, huh?

Or, in java

public class !CondOpTest? {

public static void main(String[] args) {

new !CondOpTest?(new Integer(args[0?));

}

public !CondOpTest?(Integer a) {

if (a.intValue()==1) {

System.out.println("A is 1!");

} else {

System.out.println("A is not 1!");

}

}

}

becomes

public class !CondOpTest? {

public static void main(String[] args) {

new !CondOpTest?(new Integer(args[0?));

}

public !CondOpTest?(Integer a) {

System.out.println((a.intValue()==1 ) ? "A is 1!" : "A is not 1!");

}

}

In Perl, however, things are slightly different.

This piece of code is valid, and is similar to the examples above
print ( ($a==1) ? "A is 1!" : "A is not 1!" );
However the following code is also valid
($a==1) ? print "A is 1!" : print "A is not 1!";

The above also works in C

int a = 0; (a == 1) ? printf("A is 1!\n") : printf("A is not 1!\n");

The following authors of this page have not agreed to the WlugWikiLicense. As such copyright to all content on this page is retained by the original authors. The following authors of this page have agreed to the WlugWikiLicense.

PHP Warning

lib/plugin/WlugLicense.php:99: Warning: Invalid argument supplied for foreach()

lib/plugin/WlugLicense.php:111: Warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument

lib/plugin/WlugLicense.php:111: Warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument