View Full Version : can someone help me with this small piece of code?
JohnBee
06-24-2005, 02:26 PM
I believe its perl.
if (file_exists($myfile)) {
include $myfile;
} else {
echo "That profile does not exist or is currently unavailable";
}
I would like to use this on my php page how can I get the equivalent
using PHP?
Marco van Herwaarden
06-24-2005, 02:36 PM
Looks good to me.
JohnBee
06-24-2005, 03:10 PM
Well.... are you saying will this work in my vbulletin templates?
because I added it in and it litterally printed the code on my screen, I don't know how come it does that.
so I was assuming this is perl and not php, I'm trying to get the equivalent
of this code in php.
Okay I tried some more and discovered that...
since I use a variable used through my style php include start I would have to somehow
get that code to work with the $myfile variable or something can someone help me
figure this out?
I basically want to display a custom message if the php include file is not present
in a vBulletin page.
Heres my attempt in my phpinclude start:
if ( file_exists("http://www.mysite.com/index.txt") )
{
ob_start();
require("http://www.mysite.com/index.txt");
$info = ob_get_contents();
ob_end_clean();
} else {
ob_start();
require("/home/www/public/web/errors/nofile.txt");
$info = ob_get_contents();
ob_end_clean();
}
it doesnt work it always returns false :(
Got it!
$includefile="http://www.mysite.com/index.txt";
$handle = fopen($includefile, "r", 1);
if ($handle) {
fclose($handle);
ob_start();
require("http://www.mysite.com/index.txt");
$info = ob_get_contents();
ob_end_clean();
} else {
ob_start();
require("/home/www/public/web/errors/nofile.txt");
$info = ob_get_contents();
ob_end_clean();
}
tried and tested
Works nicely :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.