Patch (patchwolf) wrote in php,
Patch
patchwolf
php

  • Music:

Nifty bit of code I thought I'd share...

Ever had a one page (out of an entire site) that had specific CSS no other page should share?

If you're like me, and use a common header.inc.php and footer.inc.php, including the CSS inside a <style> tag in the body won't cut it -- it fails validation if you do that. So I whipped this up last night, and slapped it into the <head> section of my header.inc.php file...


<?php if ($_SERVER['PHP_SELF'] == "/mypage.php") {
print ("<link rel=\"STYLESHEET\" type=\"text/css\" href=\"mypage.css\" />");
}
?>

It works, and it won't prevent validation from happening.
Subscribe

  • ¿ Que pasó con esta comunidad PHP ?

    Hay que revivir esta comunidad, PHP está mas vivo que nunca con su nueva versión PHP 8 liberada el pasado 26 de Noviembre 2020, en el año de la…

  • Hmm...

    Is this community dead or something?

  • Hello!

    I just started to use LJ, so i thought it would be nice to have some friends here. I'm into coding and programming. I recently started to practice…

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 4 comments