Is there any line of script i can put into a page that will change itself to the title of the page on the net ?
<?php function get_title_tag($chaine){ $fp = fopen ($chaine, 'r'); while (! feof ($fp)){ $contenu .= fgets ($fp, 1024); if (stristr($contenu, '<title>' )){ break; } } if (eregi("<title>(.*)</title>", $contenu, $out)) { return $out[1]; } else{ return false; } } ?> PHP: echo get_title_tag('http://www.google.com'); PHP:
is this a script which i can past into alll 300 of my pages and not have to worry about editing them individually because they all have individual titles allready ?
You just need to call the function(get_title_tag)...You just need to edit the function if there is any code changes...
Hang on, are you wanting a script to get the title of an external page thats not on your site or are you wanting a script to put a title onto all of your web pages?
Right well i have a games website and im trying to get the line add this game to your website ...... So far i have <a href="http://www.geekazoid.co.uk<?php echo $_SERVER['REQUEST_URI']; ?>">TITLE OF THE PAGE HERE</a> Because the title of my 300 games pages is the name of the game on other peoples websites it would show the name of the game as a link to my page. and i just dont want to have to manually edit each page. I jsut want to paste the line into my pages and it would grab the url ( allready done ) and the title ( yet to find script ) automatically
Right. As I understand it you want to be able to echo the page title of the current page into a link? At the top of your page add the function I wrote above. Then you need to add the following where you want the title to appear. <a href="http://www.geekazoid.co.uk<?php echo $_SERVER['REQUEST_URI']; ?>"><?php echo get_title_tag('http://www.geekazoid.co.uk$_SERVER['REQUEST_URI']'); ?></a> PHP: I assume the titles are all hard coded into your pages rather than using a CMS? If you use a CMS there should be some kind of title variable you can use.
Ok i think that would work brilliant, now just to make sure where do i put the first part the php function bit ? is it in the head ?
anywhere ? because its not working http://www.geekazoid.co.uk/Games/Games-Page/Blank.php This is the page and as you can see their must be something wrong with the code because it was working before i tried the code ? any ideas
Try this: <?php $thispage="http://www.geekazoid.co.uk$_SERVER['REQUEST_URI']"; ?> <a href="http://www.geekazoid.co.uk<?php echo $_SERVER['REQUEST_URI']; ?>"><?php echo get_title_tag('$thispage'); ?></a> PHP:
if i post the code i have ? im affraid i dont know what you mean by that... all the script i have is what you gave me
<?php function get_title_tag(){ $thesite="http://www.geekazoid.co.uk"; $thepage=$_SERVER['REQUEST_URI']; $theurl="$thesite$thepage"; $fp = fopen ("$theurl", 'r'); while (! feof ($fp)){ $contenu .= fgets ($fp, 1024); if (stristr($contenu, '<title>' )){ break; } } if (eregi("<title>(.*)</title>", $contenu, $out)) { return $out[1]; } else{ return false; } } ?> <?php ?> <html> <title>This is the title</title> <body> <a href="http://www.geekazoid.co.uk<?php echo $_SERVER['REQUEST_URI']; ?>"><?php echo get_title_tag(); ?></a> </body> </html> PHP:
From your posts here and in other posts of your origin, I would say you need to establish a minimal knowledge base. We are not here to do the job for you, and that includes elementary step by step instruction. If that's what you need, you should hire the work done. If you wish help over a sticking point, that's another thing, but it requires that you do some work and study yourself. It also requires that you have at least some skills in html, css, php and javascript. These you must gain on your own. There are myriad tutorials on each subject just waiting for you. Google is your friend. cheers, gary