简体   繁体   English

编辑一个 php 文件,文件名为 config.php

[英]Edit a php file with a php file name config.php

I want to create a file in php named config.php with some string similar to this:我想在 php 中创建一个名为 config.php 的文件,其中包含一些类似于以下内容的字符串:

$this->name = 'Example';

And in the file index.php a string like this:在文件 index.php 中有一个这样的字符串:

<title><?php echo $this->name; ?></title>

I've see this in another site but i don't know how this works, can someone help me?我在另一个网站上看到过这个,但我不知道它是如何工作的,有人可以帮助我吗? Thank you very much!非常感谢!

I try this:我试试这个:

config.php配置文件

    <?php

final class Settings {
    public static $TRUE = "1", $FALSE = "0";

    public function __construct($connect = true) {
        $this->name = 'Example';
    }


   }
?>

index.php索引.php

<html>
<head>
    <title><?php echo $this->name; ?></title>
</head>
<body>
</body>
</html>

You can take a reference from here你可以从这里参考

$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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM