php 原生模板 include 报错
<!DOCTYPE html>
<html lang="<?= trans('l') ?>">
<?php include '../layout/header.html'; ?>
<body>
<div class="layui-layout layui-layout-admin">
<?php include '../layout/menu.html' ?>
<div class="layui-body">
<div style="padding: 16px;"></div>
</div>
<?php include '../layout/password.html' ?>
</div>
<?php include '../layout/script.html' ?>
</body>
</html>
ErrorException: include(../layout/header.html): Failed to open stream: No such file or directory in D:\webman\sjk\app\view\shop\index.html:3
Stack trace:
#0 D:\webman\sjk\app\view\shop\index.html(3): support\App::{closure}(2, 'include(../layo...', 'D:\\webman\\sjk\\a...', 3)
#1 D:\webman\sjk\app\view\shop\index.html(3): include()
#2 D:\webman\sjk\vendor\workerman\webman-framework\src\support\view\Raw.php(70): include('D:\\webman\\sjk\\a...')
#3 D:\webman\sjk\support\helpers.php(201): support\view\Raw::render('shop/index', Array, '', '')
#4 D:\webman\sjk\app\controller\ShopController.php(11): view('shop/index')
#5 D:\webman\sjk\vendor\workerman\webman-framework\src\App.php(319): app\controller\ShopController->index(Object(support\Request))
#6 D:\webman\sjk\vendor\workerman\webman-framework\src\App.php(141): Webman\App::Webman\{closure}(Object(support\Request))
#7 D:\webman\sjk\vendor\workerman\workerman\Connection\TcpConnection.php(646): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#8 D:\webman\sjk\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #140)
#9 D:\webman\sjk\vendor\workerman\workerman\Worker.php(1488): Workerman\Events\Select->loop()
#10 D:\webman\sjk\vendor\workerman\workerman\Worker.php(1405): Workerman\Worker::forkWorkersForWindows()
#11 D:\webman\sjk\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()
#12 D:\webman\sjk\vendor\workerman\webman-framework\src\support\App.php(131): Workerman\Worker::runAll()
#13 D:\webman\sjk\start.php(4): support\App::run()
#14 {main}
Windows 11
PHP8.3.8
webman 1.5.5
webman-framework 1.5.19
用绝对路径
这样确实可以 但是如果部署的话不是要每个都改一遍?有没有什么简便的方法
方法一:定义一个函数
方法二:配置一个全局变量
你这么写 啥框架你也找不到
那你说该怎么写 不用绝对路径 用/开头的也行
你就没想过 引入接口然后接口渲染这里嘛
为啥用模板 就是不想用接口 要是搞接口还不如搞成前后端分离了
相对路径是从php命令行运行的地方算