473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Self referencing

How can I write a PHP code to find the URL on which the code the itself
is running?

Sorry about the question: it's a bit difficult to describe, so here is
what I am trying to achieve...

....in sort of LogicCode
If this is NOT the home page then
associate the company logo with a link to the home page
else
just display the logo without any linking reference.

TIA
Apr 28 '06 #1
5 4063
On Fri, 28 Apr 2006 21:03:54 +0800, TreatmentPlant wrote:
How can I write a PHP code to find the URL on which the code the itself is
running?


If you're running PHP as an Apache module, use $_SERVER["REQUEST_URI"].
You can combine this with $_SERVER["HTTP_HOST"] if you run it on different
hostnames (and that's important to you).

Cheers,
Andy

--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Apr 28 '06 #2
In message <44***********************@per-qv1-newsreader-01.iinet.net.au>
TreatmentPlant <tr************@DIESPAMMERS.iinet.net.au> wrote:
How can I write a PHP code to find the URL on which the code the itself
is running?

Sorry about the question: it's a bit difficult to describe, so here is
what I am trying to achieve...

...in sort of LogicCode
If this is NOT the home page then
associate the company logo with a link to the home page
else
just display the logo without any linking reference.

TIA


On the home page have something like this

<? $page="home" ?> and on the other pages
<? $page="nothome" ?>

Then where you want the image to be have

<?

if ($page=="nothome") {
Code fopr company logo and link to home page code
}
else
{
Code for logo withouth link to home page
}
?>

--
Kev Wells http://kevsoft.topcities.com
http://kevsoft.co.uk/
ICQ 238580561
Bring me my bow of burning gold!
Apr 28 '06 #3

"Kevin Wells" <ke*******@dsl.pipex.com> wrote in message
news:d4**************@pipex.com...
In message <44***********************@per-qv1-newsreader-01.iinet.net.au>
TreatmentPlant <tr************@DIESPAMMERS.iinet.net.au> wrote:
How can I write a PHP code to find the URL on which the code the itself
is running?

Sorry about the question: it's a bit difficult to describe, so here is
what I am trying to achieve...

...in sort of LogicCode
If this is NOT the home page then
associate the company logo with a link to the home page
else
just display the logo without any linking reference.

TIA


On the home page have something like this

<? $page="home" ?> and on the other pages
<? $page="nothome" ?>

Then where you want the image to be have

<?

if ($page=="nothome") {
Code fopr company logo and link to home page code
}
else
{
Code for logo withouth link to home page
}
?>


Actually, all he need do is on the homepage
<?php $page="something" ?>
and on all pages do
if (isset($page)) {
....
} else {
....
}

Shelly
Apr 28 '06 #4
On Fri, 28 Apr 2006 15:18:25 -0400, Shelly wrote:
Actually, all he need do is on the homepage <?php $page="something" ?>
and on all pages do
if (isset($page)) {
...
} else {
...
}
}


But be wary of using it for anything more than changing a link like this,
if you're running with register_globals on (I know, it's not good
practice, but there may still be some old installations or those upgraded
and kept for compatibility).

At least Kevin's version would have checked for the exact value he set
(rather than yours that would be got round with www.foo.com?page=1)

Just pointing it out for less experienced PHPers.

Cheers,
Andy

--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

May 1 '06 #5
Kevin Wells wrote:
In message <44***********************@per-qv1-newsreader-01.iinet.net.au>
TreatmentPlant <tr************@DIESPAMMERS.iinet.net.au> wrote:
How can I write a PHP code to find the URL on which the code the itself
is running?

Sorry about the question: it's a bit difficult to describe, so here is
what I am trying to achieve...

...in sort of LogicCode
If this is NOT the home page then
associate the company logo with a link to the home page
else
just display the logo without any linking reference.

TIA


On the home page have something like this

<? $page="home" ?> and on the other pages
<? $page="nothome" ?>

Then where you want the image to be have

<?

if ($page=="nothome") {
Code fopr company logo and link to home page code
}
else
{
Code for logo withouth link to home page
}
?>


Thanks all,

I have implemented Kevin's suggestion and it works like a charm.
May 2 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: SpeedBump | last post by:
This is mostly just another "gee it would be nice if it had X" post. Recently I have come across two separate problems which both exhibit the need for a way to self reference when instantiating a...
2
by: sreddy | last post by:
I am trying to write a sql query on self referencing table. Just to brief ..Database is related to a Hiring department of the Qwest company. I need to generate a Report used by in HR...
1
by: Greg Phillips | last post by:
Hello everyone, I have read the section on templates in The C++ Programming Language 3rd edition 3 times over the last 4 days. Still I am stumped. I'll explain a bit about what I am doing...
20
by: Wayne Sutton | last post by:
OK, I'm a newbie... I'm trying to learn Python & have had fun with it so far. But I'm having trouble following the many code examples with the object "self." Can someone explain this usage in...
2
by: Paul Cook | last post by:
Hi, I have three tables: Countries: ID Country States: ID
10
by: Macka | last post by:
A few pieces of information first: * I have a class called Folder which represents a row of data in a database table. The data access side of things is not an issue. * The table has a parent...
1
by: Andrew Banks | last post by:
I have a database table with the following kind of structure CategoryID (int) Parent CategoryID (int) CategoryName (varchar) The table has a self referencing relationship between...
0
by: Doug Gault | last post by:
I've been very pleased to find that you can load an XML file into a DATASET using the XMLREAD method, but I'm having a problem when trying to load a file that contains self-referencing elements. ...
1
by: vojinle | last post by:
Hi, Is there any example populating TreeView control from self-referencing database table? Table structure: ID Item_name Parent_ID
2
by: notnorwegian | last post by:
class TaskGroup: def __init__(self): self.group = def addTask(self, task): self.group.append(task) is this wrong? i have a program thats too big to post but should i just do group.append...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.