How to do If compact with constant variables (define ())? and how to know if it connects to google.fonts.com

0
  define('FONTS_ONLINE',' <link href="https://fonts.googleapis.com/css?family=Abel|Arimo:400,400i|Bree+Serif|Dosis:400,500|Oswald:400,500" rel="stylesheet">');

  define('FONTS_HOUSED','<link rel="stylesheet" href="fonts/fonts.css">');

Call the constant variables

<?php if (FONTS_ONLINE) ? FONTS_ONLINE : FONTS_HOUSED ?>
    
asked by Gamez 21.04.2017 в 21:17
source

1 answer

0

I do the following form:

functions.php

<?php
    function crear_fonts($type){
        switch($type){
            case 'local':
                $font = "<link rel=\"stylesheet\" href=\"fonts/fonts.css\">";
                break;

            case 'google':
                $font = "<link href=\"https://fonts.googleapis.com/css?family=Abel|Arimo:400,400i|Bree+Serif|Dosis:400,500|Oswald:400,500\" rel=\"stylesheet\">";
                break;
        }
        return $font;   
    }
?>

To add the font:

<?php
    include("functions.php");

    echo crear_fonts('google'); // return font google
    echo crear_fonts('local'); // return font local
?>
    
answered by 21.04.2017 в 22:02