douken7402 2014-03-25 09:44
浏览 51
已采纳

如何在php $ div中关闭double include_once

I am including two files in my index page:

$PageData = new Page_Data(); 
$PageData->title ="Welcome to my page";
$div=  "<div class='login-form'>" . include_once "views/navigation.php" . include_once "controllers/login.php" . "</div>";
$PageData->content .=$div;

And I get these two errors.

Warning: include_once(controllers/login.php): failed to open stream: No such file or directory in C:\Users\kalle_000\Documents\KEA\3rd Semester\3rd Module\Module_8\PHP_new\index.php on line 9

Warning: include_once(): Failed opening 'controllers/login.php' for inclusion (include_path='.;C:\php\pear') in C:\Users\kalle_000\Documents\KEA\3rd Semester\3rd Module\Module_8\PHP_new\index.php on line 9 test content

What am I doing wrong? All the files are in the right folder where they should be. Any help appreciated!

  • 写回答

2条回答 默认 最新

  • dongxi1320 2014-03-25 10:06
    关注

    I changed the syntax to this:

    $PageData = new Page_Data(); 
    $PageData->title ="Welcome to my page";
    $div=  "<div class='login-form'>";
    $div.= include_once ("views/navigation.php");
    $div.= include_once ("controllers/login.php");
    $div.= "</div>";
    
    
    $PageData->content .=$div;
    

    For some reason, the browser didn't understand the previous syntax, but gets this and now it works perfectly. Thanks for the help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀