Apr 14, 2011, 9:40 AM
Post #16 of 27
Re: [sunrise11] Need to change browser's title for one page
[In reply to]
Theres a few different aspects that need clarrifying.
$header and $gheader are inevitably different variables, therefore if you set $header with your php header, then use $gheader to open the file, its not going to open $header (which is a full URL not a path anyway). I explained in a previous post that in order for PHP to compile, the PHP code must be executed as php. If you open the file in perl, read it, and print its contents then the PHP isn't going to compile, instead it will compile as HTML code. You will have to use the same method whether you want to use a new title, or the default title, to be most efficient.
Thats more like it, I can't see that you are doing anything wrong here. This should work, although you may need to encode the URL. You should use this snippet of code even when you want to print the default title, just leave the value of the Title attribute empty, and the PHP script will revert to the default title.
Before trying to implement the new code into your existing code, how about creating a fresh Perl script, just to test it all out first, which you can play around with and see how it works. With this new method, you would no longer need to use open to read the header, you can simply use LWP::Simple's get method to print the output of the compiled PHP. When you are confident you understand how it works, you will have a much easier time in implementing it, and removing any unneccessary old code.