如何获得一个PHP文件做一个公司文件一样的事情?
问题描述:
现在我的所有网页都不再正确格式化,因为它不再是inc文件。我如何让PHP网页阅读另一个PHP文件并应用格式?如何获得一个PHP文件做一个公司文件一样的事情?
本来我只是用这个
<?php
readfile("balls.inc");
?>
</head>
<body>
<!--#include virtual="balls.inc"-->
但是,当然,现在这不再起作用,因为导航现在是一个php文件,如何得到相同的结果有什么建议?
答
在PHP中您可以使用包含或include_once或要求
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";
?>
这仍然保留所有以INC页面上的导航附带的格式和链接的? –
包含技术是为了包含通用代码......但最终会更新您的问题并添加适当的内容样本。 – scaisEdge
其实只是试过了,它运行良好! –