By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,738 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,738 IT Pros & Developers. It's quick & easy.

PHPSELF when used with file function

P: n/a
Hi,

I have a php file, where i am using an include from a URL

detail.php:

$html = "";
$contentFile = "http://www.mysite.com/link.php";
if ( $contentFile ) {
$fileBuffer = file($contentFile);
foreach ($fileBuffer as $tmp) {
$html .= $tmp;
}
}

------------------------
link.php contains a script which echos $PHP_SELF

when i echo it, it displays "link.php" but i want the output as
"detail.php" basically i need to echo where the link is called from..

any solution ??

thanks
murali
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Why can't you use $PHP_SELF in detail.php ?

Murali wrote:
Hi,

I have a php file, where i am using an include from a URL

detail.php:

$html = "";
$contentFile = "http://www.mysite.com/link.php";
if ( $contentFile ) {
$fileBuffer = file($contentFile);
foreach ($fileBuffer as $tmp) {
$html .= $tmp;
}
}

------------------------
link.php contains a script which echos $PHP_SELF

when i echo it, it displays "link.php" but i want the output as
"detail.php" basically i need to echo where the link is called from..

any solution ??

thanks
murali


Jul 17 '05 #2

P: n/a
Murali wrote:
[...]
when i echo it, it displays "link.php" but i want the output as
"detail.php" basically i need to echo where the link is called from..

any solution ??


Don't read the file with file(). That way you are processing it as
another page; instead simply include it

<?php include 'link.php'; ?>

--
..sig
Jul 17 '05 #3

P: n/a
Yah, but actually i need to add this html output of link.php to $html
string and print it later...

other thing which i thought is, i might pass a query string(file name)
to link.php and read that in link.php

like
file("http://www.mysite.com/link.php?pg=/mypage.php")

and in link.php i would refer to mypage.php.

i actually tried this, but for some reason, my logic which was working
is not working now.. :(

i am actually expanding a menu and collapsing a menu by passing
arguments.. something like menu=0 and menu=1.

Pedro Graca <he****@hotpop.com> wrote in message news:<bo*************@ID-203069.news.uni-berlin.de>...
Murali wrote:
[...]
when i echo it, it displays "link.php" but i want the output as
"detail.php" basically i need to echo where the link is called from..

any solution ??


Don't read the file with file(). That way you are processing it as
another page; instead simply include it

<?php include 'link.php'; ?>

Jul 17 '05 #4

P: n/a
Murali wrote:
Yah, but actually i need to add this html output of link.php to $html
string and print it later...
Make a function in link.php that returns what you need.

other thing which i thought is, i might pass a query string(file name)
to link.php and read that in link.php
That should be a parameter to the function.

like
file("http://www.mysite.com/link.php?pg=/mypage.php")

and in link.php i would refer to mypage.php.
like
<?php
// ...
require_once 'link.php';
$html .= link_function('mypage.php');
// ...
?>

i actually tried this, but for some reason, my logic which was working
is not working now.. :(

i am actually expanding a menu and collapsing a menu by passing
arguments.. something like menu=0 and menu=1.


in link.php you can define the function with those parameters too:
<?php
function link_function($page, $collapse=false) {
$retval = 'menu';
if (!$collapse) $retval .= '<br/>submenu';
return $retval;
}
?>

--
..sig
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.