2

Trying to set up templates on a site I am working on, and I want to change the linked stylesheet document instead of using PHP within the CSS. Would this be possible? Thanks.

<?php

    require 'includes/templates.php';

    if($_COOKIE['template'] == $blocky) {

        echo "<link rel="stylesheet" href="/testpages/css/blocky.css">";

    }

    else {

        echo "<link rel="stylesheet" href="/testpages/css/default.css">";

    }

?>
xThereon
  • 21
  • 1
  • 4
  • You have to escape your quotes in the string: `echo "";` so that it doesn't think that that is the end of the string. Or you can use single quotes `'` instead for it: `echo ''` – dave Apr 07 '18 at 00:22

1 Answers1

2

Yes that would possible, but make sure to escape your quotes

 <?php
    require 'includes/templates.php';

     if($_COOKIE['template'] == $blocky) {

         echo "<link rel=\"stylesheet\" href=\"/testpages/css/blocky.css\">";

     }

     else {

         echo "<link rel=\"stylesheet\" href=\"/testpages/css/default.css\">";

     }

 ?>
Sheshank S.
  • 3,053
  • 3
  • 19
  • 39