xref: /PHP-7.4/Zend/tests/008.phpt (revision 782352c5)
1--TEST--
2define() tests
3--FILE--
4<?php
5
6var_dump(define());
7var_dump(define("TRUE"));
8var_dump(define("TRUE", 1));
9var_dump(define("TRUE", 1, array(1)));
10
11var_dump(define(array(1,2,3,4,5), 1));
12var_dump(define(" ", 1));
13var_dump(define("[[[", 2));
14var_dump(define("test const", 3));
15var_dump(define("test const", 3));
16var_dump(define("test", array(1)));
17var_dump(define("test1", fopen(__FILE__, 'r')));
18var_dump(define("test2", new stdclass));
19
20var_dump(constant(" "));
21var_dump(constant("[[["));
22var_dump(constant("test const"));
23
24echo "Done\n";
25?>
26--EXPECTF--
27Warning: define() expects at least 2 parameters, 0 given in %s on line %d
28NULL
29
30Warning: define() expects at least 2 parameters, 1 given in %s on line %d
31NULL
32bool(true)
33
34Warning: define() expects parameter 3 to be bool, array given in %s on line %d
35NULL
36
37Warning: define() expects parameter 1 to be string, array given in %s on line %d
38NULL
39bool(true)
40bool(true)
41bool(true)
42
43Notice: Constant test const already defined in %s on line %d
44bool(false)
45bool(true)
46bool(true)
47
48Warning: Constants may only evaluate to scalar values, arrays or resources in %s on line %d
49bool(false)
50int(1)
51int(2)
52int(3)
53Done
54