dongtuoji5396 2018-09-15 07:52
浏览 22

在叶片层中定义变量

I'm very new here please.

I'm trying to get some information and pass it to the laravel blade to be displayed on my website. What is for sure is that the call was successful but when I try passing it to the view I get an error that says "undefined variable" in the view page and sometimes the area where information was supposed to be displayed just shows an empty space.

  • 写回答

1条回答 默认 最新

  • douzai9405 2018-09-15 14:05
    关注

    Pass your variables in the view method instead. The with function is for passing individual data, so it doesn't accept an array. Example:

    return view('profile.newaddress', [
        'address'=>$address
    ]);
    

    If you want to use with, try it like this instead (assuming $address in a string):

    return view('profile.newaddress')->with('address', $address);
    
    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)