PDA

View Full Version : Help needed: how to write different text in the Header (condition)


Cyclist
7th of November 2008 (Fri), 04:10
I would like to print different text in the header depending on the called page.

If I for instance call the list.php I want to write other text than on index.php or photo.php

Does anyone knows how I can do this? If I am not wrong the structure might look like


if (condition)
print 'text_a';
elseif (condition)
print 'text_b';
else
print 'text_c';


but I don't know how do write the condition to check the current page. It must be something like if page=list.php print text_a else.... but how do I have to write this with php?

Cyclist
7th of November 2008 (Fri), 15:37
I got the solution! Iam posting it here, maybe it will be helpfull for someone else.

<?php
if (basename($_SERVER['PHP_SELF'])== 'a.php')
{
print 'text_a';
}

elseif (basename($_SERVER['PHP_SELF'])== 'b.php')
{
print 'text_b';
}

else
{
print 'text_c';
}
?>


I don't know if it's the best solution but at least it's working for me. If somenbody knows a better way doing it I would be thankfull if he could post that one.