【问题标题】:How To Get a PHP File To Do The Same Thing As An inc File?如何让 PHP 文件做与 inc 文件相同的事情?
【发布时间】:2017-02-26 07:48:20
【问题描述】:

现在我的所有网页的格式都不再正确,因为它不再是一个 inc 文件。如何让 php 网页读取另一个 php 文件并应用格式?

原来我只是用这个

<?php
readfile("balls.inc");
?>
</head>

<body>
<!--#include virtual="balls.inc"-->

当然现在这不再有效,因为导航现在是一个 php 文件,有什么建议可以得到相同的结果吗?

【问题讨论】:

    标签: php html xhtml ssi


    【解决方案1】:

    在 PHP 中你可以使用 include 或 include_once 或 require

    include 'your_file.php';  // include each time you use the call  
    

    http://php.net/manual/it/function.include.php

    include_once 'your_file.php';  // include just one time you use the call  
    

    http://php.net/manual/en/function.include-once.php

     require 'your_file.php';  // stop execution if not find
    

    http://php.net/manual/en/function.require.php

    你的情况

    <?php
     include "navigation.php";
     ?>
    

    【讨论】:

    • 这仍然会保留公司页面上导航附带的所有格式和链接?
    • 包含技术用于包含通用代码...但最终会更新您的问题并添加您内容的适当示例..
    猜你喜欢
    • 1970-01-01
    • 2013-07-19
    • 1970-01-01
    • 2012-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-22
    • 1970-01-01
    相关资源
    最近更新 更多