Jump to content

no-include


GeorgeMoney

Recommended Posts

Can you give a bit more detail about your situation?

You can certainly say

[code]if (some test) {
  require_once('file.php');
}[/code]

But it sounds like you want something not so straightforward?  Are you trying to detect the name of the script which is including a particular file, from within that included file?
Link to comment
Share on other sites

Basically I have one index.php file. On the index.php file there is something like:
[code]<?php
require_once "includes.php";
starts();
editbutton();
if(isset($_GET['images'])) {
require_once "images.php";
} elseif(isset($_GET['contact'])) {
require_once "contactus.php";
} else {
require_once "main.php";
}
?>[/code]

The editbutton() checks if the user is logged in and adds an editbutton on top linking to a file editor if they are logged in. I also want to have the editbutton on main.php itself, so if the user wants to edit that they can easily.

But if I do that, then I have the editbutton from main.php and the editbutton from index.php both on index.php. I want it to only use index.php's edit button on index.php and main.php's edit button on main.php. Is this possible?
Link to comment
Share on other sites

You could set a variable.  Variables set in index.php can be seen by main.php.  For example

[code]... } else {
  $editbutton_displayed = true;
  require_once "main.php";
}

And in main.php:

if ($editbutton_displayed != true) {
  editbutton();
}[/code]

Another name for the variable could be "$in_index_php", which might be more appropriate.
Link to comment
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.