duanlei8119
2017-06-05 00:58
浏览 65
已采纳

Laravel 5.4中未定义的常量

I am migrating an old code from 4.2 to 5.4. My index.php is triggering the error: undefined constant CURRENCY_BEFORE assumed 'CURRENCY_BEFORE

from this line:

<select name="curreny_position">
    <option value="BEFORE"
    <?php if ($curr_pos['value'] == CURRENCY_BEFORE) echo "selected"; ?>> 
     Before
    </option>
    <option value="AFTER" <?php if ($curr_pos['value'] == CURRENCY_AFTER) echo "selected"; ?>>After
    </option>

I am not sure if this would help, but this is the callout in my settings.php file:

{
    $currency_position = self::param('site', 'curr_position')['value'];
    $currency = self::param('site', 'currency')['value'];
    switch ($currency_position) {
        case CURRENCY_BEFORE:
            return implode(' ', [$currency, number_format($amount, 2)]);
            break;
        case CURRENCY_AFTER:
            return implode(' ', [number_format($amount, 2), $currency]);
            break;
 }

what would be the proper way to define CURRENCY_BEFORE above?

图片转代码服务由CSDN问答提供 功能建议

我正在将旧代码从4.2迁移到5.4。 我的index.php正在触发错误:未定义的常量CURRENCY_BEFORE从此行假设'CURRENCY_BEFORE

 &lt; select name =  “curreny_position”&gt; 
&lt; option value =“BEFORE”
&lt;?php if($ curr_pos ['value'] == CURRENCY_BEFORE)echo“selected”;  ?&GT;&GT;  
在
&lt; / option&gt; 
&lt; option value =“AFTER”&lt;?php if($ curr_pos ['value'] == CURRENCY_AFTER)echo“selected”;  ?&gt;&gt; 
&lt; / option&gt; 
   
 
 

我不确定这是否会有所帮助,但这是我的settings.php文件中的标注 :

  {
 $ currency_position = self :: param('site','curr_position')['value']; 
 $ currency = self :: param(  'site','currency')['value']; 
开关($ currency_position){
 case CURRENCY_BEFORE:
 return implode('',[$ currency,number_format($ amount,2)]); \  n break; 
 case CURRENCY_AFTER:
 return implode('',[number_format($ amount,2),$ currency]); 
 break; 
} 
   
 \  n 

上面定义CURRENCY_BEFORE的正确方法是什么?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题