Jump to content

Inlcuding variable.


Mutley

Recommended Posts

[quote author=Mutley link=topic=115687.msg471101#msg471101 date=1164064613]
So can I do this, if I wanted to include several?

<?PHP
$id = '1';
include('folder/file.php');
$id = '2';
include('folder/file.php');
$id = '3';
include('folder/file.php');
?>
[/quote]

If you need to include a "page" several times using a different variable I would think it would be more efficient to create a function for whatever the included page is doing. But, yes, you could do that IF you don't have any elements that can't be repeated in a single call - for instance you can't declare a function twice.
Link to comment
Share on other sites

[quote author=Destramic link=topic=115687.msg471112#msg471112 date=1164065486]
well then i would do something like this:

<?php

switch($_GET['id'])
{
    case "1":
    require_once "folder/file.php";
    break;

    case "2":
    require_once "folder/file.php";
    break;

    case "3":
    require_once "folder/file.php";
    break;
}

?>

[/quote]

Doesn't show anything doing that, no errors. This is for the same file, just different URL extensions.
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.