Jump to content

Remove Code


Lol5916

Recommended Posts

Ok so I have something on my index.php like:

<?php
$filename = "install.php";
if (file_exists($filename)) {
echo "Site cannot be executed until the site is installed. <br> <a href="install.php">Click here to install site</a>";
die;
} else {
REMOVETHISCODE
?>

If else is ran how do I get it to remove every line above it until it's at the top of the file, OR how do I get it to remove that php?

Link to comment
https://forums.phpfreaks.com/topic/143860-remove-code/
Share on other sites

should be die();

 

Actually if you're not doing anything within the parenthesis they are option so die; is fine...

 

@ Lol5916

 

So once your code is installed you go to index.php and do;

 

<?php
$filename = "install.php";
if (file_exists($filename)) {
echo "Site cannot be executed until the site is installed. <br> <a href="install.php">Click here to install site</a>";
die;
} else {
REMOVETHISCODE

 

And the first time that runs successfully you want to delete those lines so it never does the check again?

Link to comment
https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754884
Share on other sites

My heads telling me the quick answer is no, because you'll be executing a script on the file that the script is running from. So as it start to write the file (without your lines) it will basically kill itself and leave you with a blank index.php

 

Seeing as the insignificance of the few lines of code why not just leave them in....

 

<?php
if (file_exists("install.php")) { echo "Site cannot be executed until the site is installed. <br> <a href="install.php">Click here to install site</a>"; die; }

REMOVETHISCODE

 

You can just make it the first line of the page

Link to comment
https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754916
Share on other sites

Actually, if you really want to get rid of it I think I've found away.

 

The first time index.php runs successfully you push it to another page

 

header('Location: sort_index.php');

 

then sort_index.php write the index file and deletes itself.

 

though i still dont think its necessary

Link to comment
https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754920
Share on other sites

echo "Site cannot be executed until the site is installed. <br> <a href="install.php">Click here to install site</a>";

 

 

 

Is a syntax error....

 

 

echo "Site cannot be executed until the site is installed. <br> <a href=\"install.php\">Click here to install site</a>";

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/143860-remove-code/#findComment-754928
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.