Bug #68216 [Nab]: gettext can not be used inside a class

From: Date: Mon, 13 Oct 2014 08:02:22 +0000
Subject: Bug #68216 [Nab]: gettext can not be used inside a class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188050@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68216&edit=1 ID: 68216 Updated by: requinix@php.net Reported by: klwang at klwang dot info Summary: gettext can not be used inside a class Status: Not a bug Type: Bug Package: Gettext related Operating System: Ubuntu 10.04 LTS PHP Version: 5.4.33 Block user comment: N Private report: N New Comment: The code you posted doesn't show what you're actually trying to do so... do it any way you'd like. Except for what you tried there with the static variable. For example, using a regular instance variable and setting it inside your constructor. Previous Comments: ------------------------------------------------------------------------ [2014-10-13 07:50:21] klwang at klwang dot info many thanks for your reply, but how can i internationalisation the string this case? thanks again! ------------------------------------------------------------------------ [2014-10-13 07:32:15] requinix@php.net You cannot use a function call in the default value of a member variable - only constants and (with PHP 5.6+) constant expressions. ------------------------------------------------------------------------ [2014-10-13 07:28:19] klwang at klwang dot info Description: ------------ when gettext use in a class, it will be not work. with an error message like below: PHP Parse error: syntax error, unexpected '(', expecting ',' or ';' in /tmp/1.php on line 3 Test script: --------------- <? class class_test{ public static $i18n_test = _("i18n test"); } echo class_test::$i18n_test; ?> Expected result: ---------------- the gettext can use inside a class Actual result: -------------- gettext can not be used inside a class ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68216&edit=1

« previous php.bugs (#188050) next »