xref: /PHP-8.0/Zend/tests/008.phpt (revision edf22962)
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')));
19
20try {
21var_dump(define("test2", new stdclass));
22} catch (TypeError $exception) {
23    echo $exception->getMessage() . "\n";
24}
25
26var_dump(constant(" "));
27var_dump(constant("[[["));
28var_dump(constant("test const"));
29
30echo "Done\n";
31?>
32--EXPECTF--
33TypeError: define(): Argument #1 ($constant_name) must be of type string, array given
34
35Warning: Constant TRUE already defined in %s on line %d
36bool(false)
37bool(true)
38bool(true)
39bool(true)
40
41Warning: Constant test const already defined in %s on line %d
42bool(false)
43bool(true)
44bool(true)
45define(): Argument #2 ($value) cannot be an object, stdClass given
46int(1)
47int(2)
48int(3)
49Done
50