>  Q&A  >  본문

PHP Smarty의 포함 파일 문제에 대한 긴급 도움이 필요합니다!

捕获.JPG

사진은 내 사이트 디렉토리이고, index.php는 루트 디렉토리에 있고, head.php와 인스턴스화된 smarty 클래스 파일(config.php)은 include 디렉토리에 있고, 템플릿은 index.html과 head를 저장합니다. html 파일 목차.

index.php와 head.php에서 각각 클래스를 인스턴스화한 다음 속성을 할당하고 해당 HTML 파일을 표시한 다음 {include file='head.html in index.html '}을 사용한 이유를 묻고 싶습니다. 제가 head.php에 지정한 변수가 존재하지 않는 건가요? index.php 및 head.php에 각각 액세스하는 것이 정상입니다.

index.php 파일

<?php
require_once 'include/config.php';
$sm->assign('title','hello');
$sm->display('templates/index.html');
?>

index.html 파일

{include file='head.html'}
{$title}
</body>
</html>

head.php 파일

<?php
require_once 'config.php';
$sm->assign('hea','这是head头部');
$sm->display(FILES.'templates/head.html');
?>

head.html 파일

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
{$hea}

帅帅的阿猪帅帅的阿猪2523일 전1430

모든 응답(1)나는 대답할 것이다

  • 路过

    路过2017-10-26 08:14:36

    head.php에서 가져온 파일의 경로를 살펴보시겠어요?

    회신하다
    0
  • 帅帅的阿猪

    맞습니다. 저는 head.php와 Index.php를 별도로 액세스하는 것이 정상입니다.

    帅帅的阿猪 · 2017-10-26 09:36:11
    路过

    답변 0: 어떻게 정상으로 간주됩니까? 사용한 $sm을 인스턴스화했습니까? 그것은 $sm = new Smarty();

    路过 · 2017-10-26 09:42:39
  • 취소회신하다