How to use php to highlight different tabs in header file [on hold]

137
July 24, 2017, at 7:00 PM

On the website I'm making, there's a separate header file for all the other files. In the header theres a tab with links like 'Home', 'Contact Us' etc. What do I do to make these tabs get highlighted according to the webpage that I'm currently on? So if I'm on Home, the colour of 'Home' on the tab changes. Before I was using a common header, I would just add class="active" in separate place in the different html files. So in the Home file I would put "Home" in the active class to make it highlighted. The problem occurs when I'm using a separate header file. Is there a way to use PHP to 'detect' what file is using the header, and highlight different text accordingly? I have very basic knowledge of PHP, so I'm not sure how to go about this.
I was thinking of something along the lines of putting an "ID" on all the files, and adding an if statement in the header file? So if the document ID = ___, highlight this text. Is there a way to do that in PHP?

Answer 1

You can find various useful information about currently running script in $_SERVER global variable. Try using $_SERVER['REQUEST_URI'] or $_SERVER['SCRIPT_NAME'].

Use print_r($_SERVER) to see all available contents of $_SERVER.

READ ALSO
One-to-Many Relationship type is not showing in Studio - SugarCRM

One-to-Many Relationship type is not showing in Studio - SugarCRM

I am working in Sugarcrm 78 I am trying to create a relationship between contacts and my custom module example myorder but its not showing in type field when I select my custome module in `Related Module'

198
Php Dom Document [duplicate]

Php Dom Document [duplicate]

This question already has an answer here:

237
I was trying to run a mysqli_query with multiple inserts but it isnt working

I was trying to run a mysqli_query with multiple inserts but it isnt working

My code is as below: I am trying to insert into my database with multiple inserts at once with a mysqli_query, how do I go about it?

120
Secure hash and salt for PHP passwords

Secure hash and salt for PHP passwords

It is currently said that MD5 is partially unsafeTaking this into consideration, I'd like to know which mechanism to use for password protection

196