I can return the end of the url with $_SERVER["PHP_SELF"] however it
is the "Page Title" that I require.
Thanks
Not really. The Title is part of the response your script generates.
PHP_SELF is a value given by your Webserver and more representing the
request that cases your skript to run.
Heiko
Not just like that. To PHP, all previous output is just a random string
for all it's concerned. If the page title of the current page is of
importance, you should know it earlier on, or at least save it. If you're
in the habit of just maxing PHP & HTML, teach yourself to prepare all data
in strings before any output is generated, and just ending it with a
outputting HTML and the previous data stored.
An illustration, if your page is kind of like this:
<html>
<head><title><?php echo some_function_output(); ?></title>
<body>
<?php
mysql_connect(...);
$r =mysql_query('SELECT data FROM table');
$data = mysql_fetch_assoc($r)
echo $data['data'];
//euhm, title change?
?>
</body>
</html>
Change it to this:
<?php
$title = some_functions_output();
mysql_connect(...);
$r =mysql_query('SELECT data FROM table');
$data = mysql_fetch_assoc($r)
$content = $data['data'];
//title change
$title .= 'output succeeded';
?>
<html>
<head><title><?php echo $title; ?></title>
<body>
<?php echo $content; ?>
</body>
</html>
If that cannot be done, or you need a quick fix, here is some majorly
dirty code I'd slap a previous coder for using:
<?php
ob_start();
function get_title(){
$send_so_far = ob_get_contents();
if(preg_match('@<title[^>]*>(.*?)</title>@si',$send_so_far,$match)){
return $match[1];
}
return false;
}
?>
<html>
<head><title>foobar</title>
<body>
<?php echo get_title(); ?>
</body>
</html>
--
Rik Wasmus
[SPAM] Now temporarily looking for some smaller PHP/MySQL projects/work to
fund a self developed bigger project, mail me at rik at rwasmus.nl. [/SPAM]