Wells-it.com - Web Hosting

Echo in an include?

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.
teammatt3's picture
Moderator

He has: 1,907 posts

Joined: Sep 2003

I have no idea if this is possible...

I have this

<?php include ('header.php') ?>

'

And this

<?php

// Valid constant names
define("URL",    "http://localhost/");
define("IMAGE",    "http://localhost/images");

?>

'

How can I echo the constant in the include code?

This is what I tried but it didn't work.

<?php include (echo URL header.php) ?>

'

Is this possible? I want the include to be an exact file name without having to type in http://localhost everytime.

teammatt3's picture
Moderator

He has: 1,907 posts

Joined: Sep 2003

Geez, I'm retarded. You have to connect to the include file where the constant is before you can USE the constant.

Nevermind, I figured out a different solution.

He has: 582 posts

Joined: Jul 2005

If you could, please post your solution so anyone who may have the same problem in the future will see this post. Wink

-Kurtis
~View (and vote for) my art at BrickFish!

teammatt3's picture
Moderator

He has: 1,907 posts

Joined: Sep 2003

Well, I am just gonna do it the hard way. Just type out http://localhost for all the links.

Busy's picture
Modrater

He has: 6,157 posts

Joined: May 2001

As you are including the file, do what ever needs to be done in it (including echo), so the include is the result as well.
Depending what your intentions are you should also look at require and/or include/require_once

<?bhb if(broken){ echo("It wasn't me Smiling "); } ?>
Learn HTML the ez way - EzHTML.net

Some people are like slinkies, they dont really serve any purpose but they still bring a smile to your face when you push them down the stairs ...

He has: 57 posts

Joined: Apr 2005

It is simple.

Can't you just do

<?php
include(URL.'header.php');
?>

That should work Wink