SoCkEt7
SoCkEt7

Reputation: 2277

file_gets_content on the same server, i dont want to get the php code

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

Upvotes: 0

Views: 193

Answers (1)

masnun
masnun

Reputation: 11906

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"); 

Upvotes: 5

Related Questions