xref: /PHP-8.2/ext/intl/tests/formatter_clone.phpt (revision 74859783)
1--TEST--
2Cloning numfmt
3--EXTENSIONS--
4intl
5--FILE--
6<?php
7include_once( 'ut_common.inc' );
8$GLOBALS['oo-mode'] = true;
9$res_str = '';
10/*
11 * Clone
12 */
13$test_value = 12345.123456;
14$fmt = new NumberFormatter( "en_US", NumberFormatter::PATTERN_DECIMAL );
15$res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
16$fmt_clone = clone $fmt;
17
18$res = $fmt->setPattern("0.0" );
19if( $res === false )
20    $res_str .= ut_nfmt_get_error_message( $fmt ) . " (" . ut_nfmt_get_error_code( $fmt ) . ")\n";
21
22$res_str .= "Formatted number: " . ut_nfmt_format( $fmt, $test_value ) . "\n";
23$res_str .= "Formatted(clone) number: " . ut_nfmt_format( $fmt_clone, $test_value ) . "\n";
24echo $res_str;
25
26?>
27--EXPECT--
28Formatted number: 12345.123456
29Formatted number: 12345.1
30Formatted(clone) number: 12345.123456
31