Php:避免将函数视为字符串

时间:2012-11-05 14:54:58

标签: php escaping

我想将网站的内容视为字符串,并分配给变量。

但是,如果我写<?php $stringvariable = ' include https://api.twitter.com/1/statuses/user_timeline/USER.rss ' ?>

php将假设include函数和其中包含的地址仅仅是一个字符串。

有没有办法避免这种情况?

P.S。我可能实际上正在使用函数read_file作为一个基本的安全措施,因为我正在阅读的RSS提要被黑客入侵。

2 个答案:

答案 0 :(得分:3)

$variable = file_get_contents(URL)

答案 1 :(得分:2)

试试这个

$stringvariable = file_get_contents('https://api.twitter.com/1/statuses/user_timeline/USER.rss');

不要为了这个目的而使用INCLUDE

请注意

包含不是一个功能 - 它是控制结构! http://php.net/manual/en/function.include.php