[英]Edit a php file with a php file name config.php
我想在 php 中创建一个名为 config.php 的文件,其中包含一些类似于以下内容的字符串:
$this->name = 'Example';
在文件 index.php 中有一个这样的字符串:
<title><?php echo $this->name; ?></title>
我在另一个网站上看到过这个,但我不知道它是如何工作的,有人可以帮助我吗? 非常感谢!
我试试这个:
配置文件
<?php
final class Settings {
public static $TRUE = "1", $FALSE = "0";
public function __construct($connect = true) {
$this->name = 'Example';
}
}
?>
索引.php
<html>
<head>
<title><?php echo $this->name; ?></title>
</head>
<body>
</body>
</html>
你可以从这里参考
$my_file = 'config.php';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
$data = 'This is the data';
fwrite($handle, $data);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.