View Full Version : [PHP] file_get_contents?
JamesRouale
29-05-2007, 05:33 PM
I am trying to use the file_get_contents to check a variable in a different document however it's not checking the document (index.php) and then echo the result.
<?php
$license = file_get_contents("index.php");
$license = "Copyright 2007, all rights reserved.";
if ($license == FALSE){
echo"You cannot remove the copyright disclaimer!";
}
else
{
}
?>
Luckyrare
29-05-2007, 05:45 PM
I dont see how that code would work...
<?php
$source = file_get_contents("index.php");
if (eregi('Copyright 2007, all rights reserved', $source)) {
print("Copyright present");
}
else{
print("Copyright not present");
}
?>
Try that
JamesRouale
29-05-2007, 05:53 PM
Works great, thanks Danny.
JamesRouale
29-05-2007, 06:28 PM
Is there anyway that it if the copyright is present that it will do nothing if not it will die and echo "Copyright not present"?
Luckyrare
29-05-2007, 06:32 PM
<?php
$source = file_get_contents("index.php");
if (!eregi('Copyright 2007, all rights reserved', $source)) {
exit("Copyright not present");
}
?>
There ;)
JamesRouale
29-05-2007, 06:36 PM
Many thanks again Danny.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.