xref: /PHP-8.1/Zend/tests/008.phpt (revision 53aed48e)
1--TEST--
2define() tests
3--FILE--
4<?php
5
6try {
7    var_dump(define(array(1,2,3,4,5), 1));
8} catch (TypeError $e) {
9    echo "TypeError: ", $e->getMessage(), "\n";
10}
11
12var_dump(define("TRUE", 1));
13var_dump(define(" ", 1));
14var_dump(define("[[[", 2));
15var_dump(define("test const", 3));
16var_dump(define("test const", 3));
17var_dump(define("test", array(1)));
18var_dump(define("test1", fopen(__FILE__, 'r')));
19var_dump(define("test2", new stdclass));
20
21var_dump(constant(" "));
22var_dump(constant("[[["));
23var_dump(constant("test const"));
24
25echo "Done\n";
26?>
27--EXPECTF--
28TypeError: define(): Argument #1 ($constant_name) must be of type string, array given
29
30Warning: Constant TRUE already defined in %s on line %d
31bool(false)
32bool(true)
33bool(true)
34bool(true)
35
36Warning: Constant test const already defined in %s on line %d
37bool(false)
38bool(true)
39bool(true)
40bool(true)
41int(1)
42int(2)
43int(3)
44Done
45