Annotation of embedaddon/php/ext/standard/tests/general_functions/is_callable_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test is_callable() function : usage variations - undefined functions
! 3: --INI--
! 4: precision=14
! 5: error_reporting = E_ALL & ~E_NOTICE | E_STRICT
! 6: --FILE--
! 7: <?php
! 8: /* Prototype: bool is_callable ( mixed $var [, bool $syntax_only [, string &$callable_name]] );
! 9: Description: Verify that the contents of a variable can be called as a function
! 10: In case of objects, $var = array($SomeObject, 'MethodName')
! 11: */
! 12:
! 13: /* Prototype: void check_iscallable( $functions );
! 14: Description: use iscallable() on given string to check for valid function name
! 15: returns true if valid function name, false otherwise
! 16: */
! 17: function check_iscallable( $functions ) {
! 18: $counter = 1;
! 19: foreach($functions as $func) {
! 20: echo "-- Iteration $counter --\n";
! 21: var_dump( is_callable($func) ); //given only $var argument
! 22: var_dump( is_callable($func, TRUE) ); //given $var and $syntax argument
! 23: var_dump( is_callable($func, TRUE, $callable_name) );
! 24: echo $callable_name, "\n";
! 25: var_dump( is_callable($func, FALSE) ); //given $var and $syntax argument
! 26: var_dump( is_callable($func, FALSE, $callable_name) );
! 27: echo $callable_name, "\n";
! 28: $counter++;
! 29: }
! 30: }
! 31:
! 32: echo "\n*** Testing is_callable() on undefined functions ***\n";
! 33: $undef_functions = array (
! 34: "", //empty string
! 35: '',
! 36: " ", //string with a space
! 37: ' ',
! 38: "12356",
! 39: "\0",
! 40: '\0',
! 41: "hello world",
! 42: 'hello world',
! 43: "welcome\0",
! 44: 'welcome\0',
! 45: "==%%%***$$$@@@!!",
! 46: "false",
! 47: "\070",
! 48: '\t', //escape character
! 49: '\007',
! 50: '123',
! 51: 'echo()'
! 52: );
! 53:
! 54: /* use check_iscallable() to check whether given string is valid function name
! 55: * expected: true with $syntax = TRUE
! 56: * false with $syntax = FALSE
! 57: */
! 58: check_iscallable($undef_functions);
! 59:
! 60: ?>
! 61: ===DONE===
! 62: --EXPECTF--
! 63: *** Testing is_callable() on undefined functions ***
! 64: -- Iteration 1 --
! 65: bool(false)
! 66: bool(true)
! 67: bool(true)
! 68:
! 69: bool(false)
! 70: bool(false)
! 71:
! 72: -- Iteration 2 --
! 73: bool(false)
! 74: bool(true)
! 75: bool(true)
! 76:
! 77: bool(false)
! 78: bool(false)
! 79:
! 80: -- Iteration 3 --
! 81: bool(false)
! 82: bool(true)
! 83: bool(true)
! 84:
! 85: bool(false)
! 86: bool(false)
! 87:
! 88: -- Iteration 4 --
! 89: bool(false)
! 90: bool(true)
! 91: bool(true)
! 92:
! 93: bool(false)
! 94: bool(false)
! 95:
! 96: -- Iteration 5 --
! 97: bool(false)
! 98: bool(true)
! 99: bool(true)
! 100: 12356
! 101: bool(false)
! 102: bool(false)
! 103: 12356
! 104: -- Iteration 6 --
! 105: bool(false)
! 106: bool(true)
! 107: bool(true)
! 108:
! 109: bool(false)
! 110: bool(false)
! 111:
! 112: -- Iteration 7 --
! 113: bool(false)
! 114: bool(true)
! 115: bool(true)
! 116: \0
! 117: bool(false)
! 118: bool(false)
! 119: \0
! 120: -- Iteration 8 --
! 121: bool(false)
! 122: bool(true)
! 123: bool(true)
! 124: hello world
! 125: bool(false)
! 126: bool(false)
! 127: hello world
! 128: -- Iteration 9 --
! 129: bool(false)
! 130: bool(true)
! 131: bool(true)
! 132: hello world
! 133: bool(false)
! 134: bool(false)
! 135: hello world
! 136: -- Iteration 10 --
! 137: bool(false)
! 138: bool(true)
! 139: bool(true)
! 140: welcome
! 141: bool(false)
! 142: bool(false)
! 143: welcome
! 144: -- Iteration 11 --
! 145: bool(false)
! 146: bool(true)
! 147: bool(true)
! 148: welcome\0
! 149: bool(false)
! 150: bool(false)
! 151: welcome\0
! 152: -- Iteration 12 --
! 153: bool(false)
! 154: bool(true)
! 155: bool(true)
! 156: ==%%%***$$$@@@!!
! 157: bool(false)
! 158: bool(false)
! 159: ==%%%***$$$@@@!!
! 160: -- Iteration 13 --
! 161: bool(false)
! 162: bool(true)
! 163: bool(true)
! 164: false
! 165: bool(false)
! 166: bool(false)
! 167: false
! 168: -- Iteration 14 --
! 169: bool(false)
! 170: bool(true)
! 171: bool(true)
! 172: 8
! 173: bool(false)
! 174: bool(false)
! 175: 8
! 176: -- Iteration 15 --
! 177: bool(false)
! 178: bool(true)
! 179: bool(true)
! 180: \t
! 181: bool(false)
! 182: bool(false)
! 183: \t
! 184: -- Iteration 16 --
! 185: bool(false)
! 186: bool(true)
! 187: bool(true)
! 188: \007
! 189: bool(false)
! 190: bool(false)
! 191: \007
! 192: -- Iteration 17 --
! 193: bool(false)
! 194: bool(true)
! 195: bool(true)
! 196: 123
! 197: bool(false)
! 198: bool(false)
! 199: 123
! 200: -- Iteration 18 --
! 201: bool(false)
! 202: bool(true)
! 203: bool(true)
! 204: echo()
! 205: bool(false)
! 206: bool(false)
! 207: echo()
! 208: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>