Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.