zoukankan      html  css  js  c++  java
  • laravel-13-笔记-1

    1. laravel中跳转的方法
        return redirect("对应的路由")

    2. file_put_content('文件名', 数据." ", FILE_APPEND)FILE_APPEND追加写

    3. 响应
    <!-- 返回字符串 -->
    return  '字符串';
    <!--  返回并设置cookie -->
    return response('')->withCookie('name', '1111');
    <!-- 返回json字符串 -->
    return  response()->json(['name'=>'小明', 'age'=>23]);
    <!-- 文件下载 相对路径  相对当前正在请求的文件路径    绝对路径-->
    return response()->download('web.conf');    
    <!-- 页面跳转 -->
    return redirect('路径');
    <!-- 模版解析 -->
    return view('index');
    return view('admin.index');
    return response()->view('admin.index');

    <!-- 修改设置相应头 -->
    return response('123')->header('name','xiaoming');
    <!-- 设置返回内容并跳转 -->
    return "支付成功! <script>
        setTimeout(function() {
            location.href='路径';
        }, 3000)
    </script>";


    4. 视图
        <!-- 解析模版   -->
            return view('abc');
            <!-- 划分目录 -->
            return view('user.abc');
        <!-- 解析模版分配数据到模版 -->
            $arr = ['name'=>'xxx', 'age'=>'23'];
            return view('user.xxx',['xxx'=>$arr]);
            <!-- 模版中显示 -->
            {{$xxx['name']}}
            {{$xxx['age']}}
        <!-- 模板引擎blade -->
            默认存放位置  resource/views
            <!-- blade使用变量 -->
            return view('admin.user.index', ['title' => '用户的列表页']);
            <!-- 使用函数 -->
            当前时间 {{time()}}
            格式化字符串 {{date('Y-m-d H:i:s')}}
            字符串截取 {{mb_substr($title, 0, 2)}}
            <!-- 设置默认值 -->
            欢迎回来 {{$name or 'guest'}}
            <!-- 显示html代码 -->
            return view('admin.user.list', [
                'name' => 'xxx',
                'pages' => '<a href="1.html">12</a><a href="2.html">22</a>'
            ])
                <!-- 模版显示 -->
                分页页码:{!! $pages !!}
            <!-- 引入子视图 -->
            @include('page.header')
            @include('page.footer')
            @include('banner')
            <!-- 模版继承 -->
             @extends('layout.index')
             <!-- 标记 -->
             @yield('title')

             <!-- 标记显示 -->
             @section('title', '继承页面')

             <!-- 块标记 -->
             @section('content')
             fgfgfg
             @show()
             <!-- 空标记 -->
             @section('js')
             @show()
             <!-- 块标记显示 -->
             @section('content')
             eeeeee
             @endsection
             <!-- 空标记使用 -->
             @section('content')
             @endsection

        <!-- 流程控制 -->
            @if($total > 90 || $total <=100)
            飞机
            @elseif($total >60 || $total < 90)
            钢笔
            @else
            锤子
            @endif

        <!-- 循环控制 -->
            @for($i=1;$i<=100;$i++)
            {{$i}}
            @endfor
            @foreach($users as $k => $v)
                名字:{{$v['name']}}
                年龄:{{$v['age']}}
            @endforeach

  • 相关阅读:
    [整理III]微软等数据结构+算法面试100题[最新第61-80题]
    横空出世,席卷互联网--评微软等公司数据结构+算法面试100题
    SQL Server2008创建约束图解
    sqlserver2008中如何用右键可视化的设置外键
    SQL的主键和外键约束
    Visual Basic|VB 6.0中文版
    java 用eclipse j2ee写的servlet 程序,WEB-INF下的配置文件web.xml在哪啊?谢谢!
    SQL Server数据的导入导出
    MySQL命令行导出数据库
    VS2010数据库连接问题
  • 原文地址:https://www.cnblogs.com/lx0715/p/10176803.html
Copyright © 2011-2022 走看看