用消息检索变量

时间:2016-05-23 07:31:05

标签: php laravel-5

我正在尝试以这种方式检索变量以及消息。但是,我才知道这实际上不是一种方式。 $count是与消息一起显示的变量。

   public function now(Request $request)
      {
            $name=$request->get('name');
            $contact=$request->get('contact');
            $level=$request->get('level');

            $count=$level*3.5;
            return redirect('/lost')
                    ->with ('message','You have increased your level to $count.');
        }

2 个答案:

答案 0 :(得分:1)

这将有效:

<强> PHP

   public function now(Request $request)
   {
         $name=$request->get('name');
         $contact=$request->get('contact');
         $level=$request->get('level');

         $count=$level*3.5;
         return redirect('/lost')
                 ->with ('message','You have increased your level to ' . $count . ' .');
     }

答案 1 :(得分:0)

只需更改

with ('message','You have increased your level to $count.'); 

with ('message',"You have increased your level to $count."); 

(双引号而不是单引号)

您可能会看到this了解差异