• <i id='eA3UU'><tr id='eA3UU'><dt id='eA3UU'><q id='eA3UU'><span id='eA3UU'><b id='eA3UU'><form id='eA3UU'><ins id='eA3UU'></ins><ul id='eA3UU'></ul><sub id='eA3UU'></sub></form><legend id='eA3UU'></legend><bdo id='eA3UU'><pre id='eA3UU'><center id='eA3UU'></center></pre></bdo></b><th id='eA3UU'></th></span></q></dt></tr></i><div id='eA3UU'><tfoot id='eA3UU'></tfoot><dl id='eA3UU'><fieldset id='eA3UU'></fieldset></dl></div>

    <legend id='eA3UU'><style id='eA3UU'><dir id='eA3UU'><q id='eA3UU'></q></dir></style></legend>

    <tfoot id='eA3UU'></tfoot>

    <small id='eA3UU'></small><noframes id='eA3UU'>

        <bdo id='eA3UU'></bdo><ul id='eA3UU'></ul>
      1. 使用 Laravel 框架包含 PHP 文件

        Including PHP files with Laravel framework(使用 Laravel 框架包含 PHP 文件)

              <tbody id='V5daI'></tbody>
            <i id='V5daI'><tr id='V5daI'><dt id='V5daI'><q id='V5daI'><span id='V5daI'><b id='V5daI'><form id='V5daI'><ins id='V5daI'></ins><ul id='V5daI'></ul><sub id='V5daI'></sub></form><legend id='V5daI'></legend><bdo id='V5daI'><pre id='V5daI'><center id='V5daI'></center></pre></bdo></b><th id='V5daI'></th></span></q></dt></tr></i><div id='V5daI'><tfoot id='V5daI'></tfoot><dl id='V5daI'><fieldset id='V5daI'></fieldset></dl></div>
            • <tfoot id='V5daI'></tfoot>

              <legend id='V5daI'><style id='V5daI'><dir id='V5daI'><q id='V5daI'></q></dir></style></legend>

              1. <small id='V5daI'></small><noframes id='V5daI'>

                • <bdo id='V5daI'></bdo><ul id='V5daI'></ul>
                  本文介绍了使用 Laravel 框架包含 PHP 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将 php 脚本包含"到我的一个视图 (landing.blade.php) 中.

                  I am trying to "include" a php script into one of my views (landing.blade.php).

                  脚本在:

                  /laravel-master/public/assets/scripts/config.php
                  

                  当我尝试在视图中包含此代码时:

                  When I try to include this code in the view:

                  <?php include_once('/assets/scripts/config.php'); ?>
                  

                  我得到错误:include_once(/assets/scripts/config.php): failed to open stream: No such file or directory

                  这是在本地主机上使用 MAMP.我不确定是否需要在 Laravel 4 中使用一组不同的规则来包含一个 php 文件.感谢您的帮助!

                  This is on localhost using MAMP. I'm not sure if there is a different set of rules I need to use with Laravel 4 to include a php file. Thank you for your help!

                  推荐答案

                  首先,不建议您将 PHP 文件保存在 public 目录中,它们应该保存在 中app 文件夹.我建议您在 app 中创建一个文件夹,例如 includes 并将您的文件放在那里.然后,包含它,执行以下操作:

                  First, it's not really recommended that you keep your PHP files in the public directory, they should be kept inside the app folder. I'd suggest you create a folder inside app, something like includes and put your files there. Then, you include it, do:

                  include(app_path().'/includes/config.php');
                  

                  虽然,由于您似乎正在尝试加载一些配置文件,我还是建议您查看 Laravel 自己处理配置的方式.例如,如果你在 app/config 文件夹中创建了一个 myapp.php 文件,Laravel 会自动为你处理它,只要你有一些关键 -值对,像这样:

                  Although, since it looks like you're trying to load some configuration files, I'd recommend you also check out Laravel's own way of handling configurations. For instance, if you created a myapp.php file inside the app/config folder, Laravel would handle it automatically for you, as long as you'd have some key-value pairs, like this:

                  <?php
                  
                  return [
                      'name'     => 'Raphael',
                      'gorgeous' => true
                  ];
                  

                  然后您可以使用 Config 类检索这些值:

                  You could then retrieve these values using the Config class:

                  Config::get('myapp.name'); // Raphael
                  

                  这是一个更好的解决方案,因为您还可以利用 Laravel 的 环境配置.

                  This is a better solution because you can also take advantage of Laravel's environment configuration.

                  这篇关于使用 Laravel 框架包含 PHP 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <i id='Lt0Pj'><tr id='Lt0Pj'><dt id='Lt0Pj'><q id='Lt0Pj'><span id='Lt0Pj'><b id='Lt0Pj'><form id='Lt0Pj'><ins id='Lt0Pj'></ins><ul id='Lt0Pj'></ul><sub id='Lt0Pj'></sub></form><legend id='Lt0Pj'></legend><bdo id='Lt0Pj'><pre id='Lt0Pj'><center id='Lt0Pj'></center></pre></bdo></b><th id='Lt0Pj'></th></span></q></dt></tr></i><div id='Lt0Pj'><tfoot id='Lt0Pj'></tfoot><dl id='Lt0Pj'><fieldset id='Lt0Pj'></fieldset></dl></div>
                      <tfoot id='Lt0Pj'></tfoot>

                      <small id='Lt0Pj'></small><noframes id='Lt0Pj'>

                        <bdo id='Lt0Pj'></bdo><ul id='Lt0Pj'></ul>

                            <tbody id='Lt0Pj'></tbody>
                          <legend id='Lt0Pj'><style id='Lt0Pj'><dir id='Lt0Pj'><q id='Lt0Pj'></q></dir></style></legend>