(PHP 5 >= 5.3.2, PHP 7, PHP 8, PECL intl >= 2.0.0)
ResourceBundle::get -- resourcebundle_get — 從套件組合取得資料
物件導向風格
程序式風格
透過索引或字串鍵值從資源包中取得資料。
返回位於索引處的資料,或發生錯誤時返回 null
。字串、整數和二進位字串會以對應的 PHP 類型返回,整數陣列會以 PHP 陣列返回。複雜類型會以 ResourceBundle 物件返回。
版本 | 說明 |
---|---|
8.4.0 |
如果偏移類型無效,則會拋出 TypeError。如果 index 是 string 且為空,或是 int 且不符合 32 位元整數類型,則會拋出 ValueError。
|
範例 #1 resourcebundle_get() 範例
<?php
$r = resourcebundle_create( 'es', "/usr/share/data/myapp");
echo resourcebundle_get($r, 'somestring');
?>
範例 #2 物件導向範例
<?php
$r = new ResourceBundle( 'es', "/usr/share/data/myapp");
echo $r->get('somestring');
?>
上述範例將輸出
?Hola, mundo!