I am a beginner in php, and I would like to ask for some help in relating to the installation of a line of code in the header of a php file.
I am working with an OS shop and trying to install a different css file for some of its sections.
CSS are in the head, and the head is in a the template_top.php file.
I would like to set css files for contact.php, product_info.php and some others.
The idea is to set an if condition to detect the page, which would set this line:
<link rel="stylesheet" type="text/css" href="stylesheet-b.css" />
in the head among the other css links.
Is it posible?
Thanks.
Help with if condition
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Help with if condition
Yes it's possible
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
Logaritmator
- Forum Newbie
- Posts: 2
- Joined: Mon Oct 31, 2011 12:55 pm
Re: Help with if condition
I have tried with this:
But it results in a 500 server error
Some clue?
Code: Select all
<?php
$url = $_SERVER[''REQUEST_URI''];
$base = basename($url);
if($base == "index.php"){
echo <link rel="stylesheet" type="text/css" href="stylesheet-b.css"/>;}
?> Some clue?
Re: Help with if condition
Well if you really did two single quotes on each side of REQUEST_URI, then yeah, that will error.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Help with if condition
Wouldn't $_SERVER['PHP_SELF'] by a better option for your script?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering