dongzichan2886 2013-06-26 17:34
浏览 34
已采纳

在同一台服务器上的file_get_content,我不想获取php代码

I know that file_gets_content on a php file hosted on the same server return the text and the PHP code, but I dont want to have the PHP code how to do that ?

Ex :

<?php function getOneExp(){
$fp=file_get_contents("exp.txt");
$exp=  (explode(',',$fp));
shuffle($exp);
return str_replace(" ","-",utf8_decode(trim(ucfirst(strtolower($exp[0])))));
}
?>

SOME TEXT <? echo getOneExp() ?> ANOTHER TEXT

If I make a file gets content on this file I get the php too, because its on the same server, but I dont want to have the PHP,

Any ideas ?

Thanks

  • 写回答

1条回答 默认 最新

  • duanke0178 2013-06-26 17:44
    关注

    Using include is a much better solution but if you don't like it, here's an alternative for you.

    You can use either cURL or file_get_contents() with the actual web url. For example, if your domain name is example.com and the file name is test.php, then you can use this inside another php file -

    <?php
    $output = file_get_contents("http://example.com/test.php"); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。