Home > Backend Development > PHP Tutorial > 如何让文件流的变量运行?

如何让文件流的变量运行?

WBOY
Release: 2016-06-23 14:15:34
Original
877 people have browsed it

1.文本文件a.txt,里面写的是$a
2.我有一个my.php,里面是这样的写的

<?php$a="ok";file_get_content("a.txt","r+");//这是操作代码,我不会//文件读进来了,我马上要再保存成文本,但是我想把文本里面的$a换成php里面$a的值okfile_put_content("b.txt","w+");
Copy after login


文本读入php,里面的东西好像不会和php起反应,打开是$a,在php里面跑了一圈保存了还是$a,有没有办法让文件流里面的变量在php里面运行呢?

即含有$a的a.txt -----> 读入php-------->含有ok的a.txt


回复讨论(解决方案)

文本替换
ob + eval
ob + include
ob + phar

看一下字符串函数吧。

大概猜测你需要用eval这个函数

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template