作者cyenow (葡萄柚)
看板PHP
标题Re: [请益] 在PHP中汇入内含命令的TXT...?
时间Thu Feb 1 11:29:25 2007
※ 引述《SmallBeeWayn (喵喵叫的蜜蜂猫)》之铭言:
: 标题很难懂...我写了以下程式如下
: test.php===============
: <html><body>
: <?php
: $test="测试文字<BR>";
: echo include('./ta.php');
: echo file_get_contents('./tb.txt');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
用str_replace()函数
echo str_replace('$test',$test, file_get_contents('./tb.txt'));
这样应该就可以了
: ?>
: </body></html>
: ta.php=================
: <?php return "$test"; ?>
: tb.txt=================
: $test
: =======================
: 之後执行test.php时输出的结果为
: 测试文字
: $test
: 请问我应该要如何做才能让输出结果为
: 测试文字
: 测试文字
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.216.81.26
1F:推 SmallBeeWayn:这样一次只能换一个耶.... 02/01 12:38
2F:→ antontw:自已写个 loop 不行吗? 02/01 13:08
3F:推 SmallBeeWayn:与其写一堆判断乾脆乖乖加php框框.... 02/01 14:05