From 4a8ed7ab68a398d8eb79ab4d82c5e30e3f496fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schl=C3=BCter?= Date: Wed, 21 Nov 2007 00:03:16 +0000 Subject: - MFH ?: operator (Marcus) [DOC] "expr1 ?: expr1" is a shortcut for: "expr1 ? expr1 : expr2" as exists in gcc and discussed some time back. Note that this is not an implementation ifsetor($var, default). While ifsetor would not generate any message for non existing variables or array indices the ternary shortcut does. Also the ternary shortcut does a boolean evaluation rather then checking for isset(). That way ther ternary shortcut can work on any expression while ifsetor can only work on variables. Also to be silent one has do do: "@$expr1 ?: $expr2". --- Zend/tests/021.phpt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Zend/tests/021.phpt (limited to 'Zend/tests/021.phpt') diff --git a/Zend/tests/021.phpt b/Zend/tests/021.phpt new file mode 100644 index 0000000000..99fdb50258 --- /dev/null +++ b/Zend/tests/021.phpt @@ -0,0 +1,27 @@ +--TEST-- +?: operator +--FILE-- + +--EXPECT-- +bool(true) +bool(true) +int(23) +string(3) "bar" +int(23) +float(23.5) +int(1) -- cgit v1.2.1