Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

60 users online



echo inside a include

echo inside a include

Currently viewing this thread: 1 (0 members and 1 guests)


colincameron

colincameron

Neverside Newbie
Status: Offline!

echo inside a include

im trying to echo some info into a include statement, this is what i got:

PHP:

<?php

$url_path 
"http://someurl.com/";

if (
$page == "home") {
    include(
'about.htm');  
    }

?>

i want to echoe the url_path into the include, ie

PHP:

<?php

$url_path 
"http://someurl.com/";

if (
$page == "home") {
    include(
'[b]<echo right here>[/b]about.htm');  
    }

?>

Natural_Cause

Natural_Cause

Status: Offline!
Code:


$url_path = "http://someurl.com/";

if ($page == "home") {
include($url_path +'about.htm');
}

___________________

http://whatpulse.bounceme.net/sig/naturalcause.png

MinDFreeZ

MinDFreeZ

Status: Offline!
PHP:

<?php
$url_path 
"http://someurl.com/";
if (
$page == "home") {
    include(
'$url_pathabout.htm');  
}
?>

or take away the trailing slash..

PHP:

<?php
$url_path 
"http://someurl.com";
if (
$page == "home") {
    include(
'$url_path/about.htm');  
}
?>


Is there some kind of problem with doing this that I don't see?

but if home is the index page, you may want to put
if (($page == "home") or ($page =="")) { code }

___________________

http://www.enhancedps.com/images/random/crap/sig.gif

Last edited by MinDFreeZ, November 4th, 2004 02:30 PM (Edited 1 times)

colincameron

colincameron

Neverside Newbie
Status: Offline!

not sure, i will try

thanks for the help

DanneDA

DanneDA

former "D A"
Status: Offline!
PHP:

<?php

$url_path 
"http://someurl.com";
if (
$page == "home") {
    include(
$url_path.'/about.htm');  
}

?>

that should work

Nem

Nem

Status: Offline!

Skip all that and use exactly what D A wrote. Learn from it to so you know for the future how to do it.

Look at the dot in between $url_path and '/about.htm'. The dot connects $url_path to '/about.htm' when it is parsed. There isn't much more to it, re-read what i just said a few times if it doesn't.

MinDFreeZ

MinDFreeZ

Status: Offline!

I put

Quote:

Is there some kind of problem with doing this that I don't see?


because I wanted the answer D A and Nem just said.. that's useful info right there..
altho i tested it, and my way works.. his way does the same thing, and is more efficient/correct.

___________________

http://www.enhancedps.com/images/random/crap/sig.gif

colincameron

colincameron

Neverside Newbie
Status: Offline!

using this code, is there a way to change the action from getting the attribute from inside the code instead of the url

Code:

$banner = $_GET["banner"];
//this gets the query string from the url!

if ($banner == "tall") {
include($url_path.'assets/inc/banner-tall.php');
}

else if($banner == "short") {
include($url_path.'assets/inc/banner-short.php');
}

if i put this at the top of the file, is there an easy way to change that code?

Code:

$banner = "tall";

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0089 seconds.