如何以PHP格式执行文本

S17*_*514 5 php scripting execute

我有一个问题,我想抓取文本并执行PHP文本,但我该怎么做?例如,我在.txt文件中有这个代码:

$tweetcpitems->post('statuses/update', array('status' => wordFilter("The item Blue has             been released on Club Penguin.")));
$tweetcpitems->post('statuses/update', array('status' => wordFilter("The item Green has been     released on Club Penguin.")));
Run Code Online (Sandbox Code Playgroud)

现在问题是我抓住了这个文本,我想把它作为PHP脚本执行,我该怎么做?请帮忙!

Dan*_*anC 5

eval(file_get_contents('yourfile.txt'));
Run Code Online (Sandbox Code Playgroud)

当心!

http://php.net/manual/en/function.file-get-contents.php

http://php.net/manual/en/function.eval.php

  • 只是旁注:“eval()”+“file_get_contents()”本质上与“include”相同。如果您要这样做,不妨将 `<?php` 添加到文件的开头并使用 `include`。 (2认同)